Advertisement
Guest User

Untitled

a guest
Apr 1st, 2020
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. (define (heapsort lista)
  2. (define (wstaw xs)
  3. (if (= (length xs) 0)
  4. leaf
  5. (heap-insert (make-elem (car xs) (car xs)) (wstaw (cdr xs)))))
  6. (define (wynik h)
  7. (if (heap-empty? h)
  8. (list)
  9. (append (list (elem-val (heap-min h))) (wynik (heap-pop h)))))
  10. (wynik (wstaw lista))
  11.  
  12. )
  13.  
  14. (define x (list 2 3 1))
  15. (define y (list))
  16. (define z (list 2 2 2 3 1 0 5 4 7))
  17. (heapsort x)
  18. (heapsort y)
  19. (heapsort z)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement