Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Sift-down operation for heapification
(defvar arr #(2 4 5 6 7 8 9 10 11 12 13 14 15 3)) ; Only the last element violates the heap property (defun sift-down (arr &optional (pos (1- (length arr)))) (loop for i = pos then j for j = (floor (1- i) 2) until (or (zerop j) (> (aref arr i) (aref arr j))) do (rotatef (aref arr i) (aref arr j)) finally (return (values arr)))) (sift-down arr) (pprint arr) ; Now the heap property is restored
run
|
edit
|
history
|
help
0
Homework
S17016281_ACTIVIDAD_16
L2.4
LAB1TUT
Class I: Person Class - Define - Create - Initialize - Print
Pec2 Tests
Homework.lisp
lab1
14rec
ввод