Skills101
← All practice quizzes

Quiz: Heaps and Heap Sort Internals

5 questions · new set on every retakeNo time limitPass: 60%+10 XP on first pass

How a binary heap really works inside: the array layout, sift up and sift down, why building a heap is O(n), how heap sort uses it, and top-k with Python's heapq and Java's PriorityQueue.

Log in to take the quiz

Free account · see your score, answers and explanations, earn XP

  1. Question 1

    In the array form of a heap, what are the children of the node at index 4?

  2. Question 2

    What is the parent index of the node at index 6?

  3. Question 3

    What does this print?

    import heapq
    a = [5, 3, 8, 1]
    heapq.heapify(a)
    print(a[0], sorted(a) == a)
    
  4. Question 4

    A new value is pushed onto a min-heap. Where is it placed first, and which way does it move?

  5. Question 5

    During sift down in a min-heap, the node is swapped with:

🎯 Today’s placement challenge — 10 questions, no login. Can you score 10/10?Take today’s challenge →