Skip to content

Commit c78d994

Browse files
committed
Heapsort exercises
1 parent 7b881b4 commit c78d994

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/algorithms/extra-info/HSInfo.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,21 @@ Geeks for Geeks Link: [**Heap Sort**][G4GLink]
2020

2121
[G4GLink]: https://www.geeksforgeeks.org/heap-sort/
2222

23+
Many teaching resources say the best case for Heap sort is O(n log n).
24+
However, there is a case where it is O(n) - can you figure out what it is?
25+
26+
Here we have presented the "bottom up" way of creating a heap from an
27+
unsorted array. There is also a "top down" method where we start with
28+
just the first element of the array (which can be considered a heap)
29+
and repeatedly include the next element in the array until all array
30+
elements are included in the heap. At each stage some elements may need
31+
to be rearranged to ensure the heap condition is met (using an operation
32+
normally called *UpHeap*). Work out (or look up) the details of this
33+
algorithm. Try to work out (or look up) the worst case time complexity
34+
for these two ways of creating a heap.
35+
36+
Heaps are an efficient way of implementing the *piority queue* abstract
37+
data type. What operations does this ADT support and how can they
38+
be implemented using a heap? What are priority queues useful for?
39+
Can you find some algorithms in AIA that use priority queues?
2340

0 commit comments

Comments
 (0)