How to resolve the algorithm Sorting algorithms/Strand sort step by step in the PicoLisp programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Sorting algorithms/Strand sort step by step in the PicoLisp programming language
Table of Contents
Problem Statement
Implement the Strand sort. This is a way of sorting numbers by extracting shorter sequences of already sorted numbers from an unsorted list.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Sorting algorithms/Strand sort step by step in the PicoLisp programming language
Source code in the picolisp programming language
(de strandSort (Lst)
(let Res NIL # Result list
(while Lst
(let Sub (circ (car Lst)) # Build sublist as fifo
(setq
Lst (filter
'((X)
(or
(> (car Sub) X)
(nil (fifo 'Sub X)) ) )
(cdr Lst) )
Res (make
(while (or Res Sub) # Merge
(link
(if2 Res Sub
(if (>= (car Res) (cadr Sub))
(fifo 'Sub)
(pop 'Res) )
(pop 'Res)
(fifo 'Sub) ) ) ) ) ) ) )
Res ) )
You may also check:How to resolve the algorithm Accumulator factory step by step in the Oz programming language
You may also check:How to resolve the algorithm Environment variables step by step in the Sidef programming language
You may also check:How to resolve the algorithm Multisplit step by step in the Swift programming language
You may also check:How to resolve the algorithm Knight's tour step by step in the PostScript programming language
You may also check:How to resolve the algorithm Zero to the zero power step by step in the Symsyn programming language