Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,19 @@
|
|||
(de heapSort (A Cnt)
|
||||
(let Cnt (length A)
|
||||
(for (Start (/ Cnt 2) (gt0 Start) (dec Start))
|
||||
(siftDown A Start (inc Cnt)) )
|
||||
(for (End Cnt (> End 1) (dec End))
|
||||
(xchg (nth A End) A)
|
||||
(siftDown A 1 End) ) )
|
||||
A )
|
||||
|
||||
(de siftDown (A Start End)
|
||||
(use Child
|
||||
(for (Root Start (> End (setq Child (* 2 Root))))
|
||||
(and
|
||||
(> End (inc Child))
|
||||
(> (get A (inc Child)) (get A Child))
|
||||
(inc 'Child) )
|
||||
(NIL (> (get A Child) (get A Root)))
|
||||
(xchg (nth A Root) (nth A Child))
|
||||
(setq Root Child) ) ) )
|
||||
Loading…
Add table
Add a link
Reference in a new issue