diff options
author | Franciszek Malinka <franciszek.malinka@gmail.com> | 2021-10-05 21:49:54 +0200 |
---|---|---|
committer | Franciszek Malinka <franciszek.malinka@gmail.com> | 2021-10-05 21:49:54 +0200 |
commit | c5fcf7179a83ef65c86c6a4a390029149e518649 (patch) | |
tree | d29ffc5b86a0d257453cedcf87d91a13d8bf3b0d /semestr-2/racket/solution.rkt | |
parent | f8a88b6a4aba1f66d04711a9330eaba49a50c463 (diff) |
Duzy commit ze smieciami
Diffstat (limited to 'semestr-2/racket/solution.rkt')
-rw-r--r-- | semestr-2/racket/solution.rkt | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/semestr-2/racket/solution.rkt b/semestr-2/racket/solution.rkt new file mode 100644 index 0000000..3643668 --- /dev/null +++ b/semestr-2/racket/solution.rkt @@ -0,0 +1,14 @@ +#lang racket + +(provide heapsort) (require "leftist.rkt") + +(define (heapsort xs) + (define (create-heap xs res) + (if (null? xs) + res + (create-heap (cdr xs) (heap-insert (cons (car xs) (car xs)) res)))) + (define (heap-to-list h) + (if (heap-empty? h) + null + (cons (elem-val (heap-min h)) (heap-to-list (heap-pop h))))) + (heap-to-list (create-heap xs empty-heap)))
\ No newline at end of file |