Self-Review Questions

  1. What is the worst-case runtime complexity of finding the smallest item in a min-heap?
    O(1)

  2. What is the worst-case runtime complexity of finding the largest item in a min-heap?
    O(n)

  3. What is the worst-case runtime complexity of deleteMin in a min-heap?
    O(log n)

  4. What is the worst-case runtime complexity of building a heap by insertion?
    O(n log n)

  5. Is a heap full or complete binary tree?
    complete

  6. What is the worst-time runtime complexity of sorting an array of N elements using heapsort?
    O(n log n)

  7. Given a sequence of numbers: 1, 2, 3, 4, 5
    1. Draw a binary min-heap (in a tree form) by inserting the above numbers reading them from left to right
    2. Show a tree that can be the result after the call to deleteMin() on the above heap

  8. Given a sequence of numbers: 1, 2, 3, 4, 5
    1. Draw a binary max-heap (in a tree form) by inserting the above numbers reading them from left to right
    2. Show a tree that can be the result after the call to deleteMax() on the above heap