0

Quiz Question

Got this problem on a recent CS class quiz that I got wrong. These were the choices:

  • 3,4
  • 10,13
  • 10, 9
  • 10

I put 10 and am pretty sure I am right. Can someone explain why I am not?

John Kugelman
  • 349,597
  • 67
  • 533
  • 578

1 Answers1

0

It's been a long time, but here's how it should work:

  • Remove 1 creating new heaps 2->10 and 9 (orders 1 and 0).
  • Merge these with the rest of the heap.
  • 2->10 stays as-is. There's no other order 1 heap (for now).
  • Merge 9 and 13 into 9->13.
  • Now merge 9->13 and 2->10 to get a new order 2 heap.
   2->10
    -> 9->13
  • There's no other order 2 heap, so we're done.

So the children of 2 are 9,10.

Gene
  • 46,253
  • 4
  • 58
  • 96