Heap

A minimum heap is a list of numbers such that the ithi^\text{th} number is smaller than the (2i)th(2i)^\text{th} and (2i+1)th(2i+1)^\text{th} numbers. For example, L={1,2,3,3,5,4,7}L = \{1, 2, 3, 3, 5, 4, 7\} is a minimum heap because

  • the 1st1^\text{st} number is smaller than the 2nd2^\text{nd} and 3rd3^\text{rd} numbers;
  • the 2nd2^\text{nd} number is smaller than the 4th4^\text{th} and 5th5^\text{th} numbers;
  • the 3rd3^\text{rd} number is smaller than the 6th6^\text{th} and 7th7^\text{th} numbers.

Conversely, a maximum heap is a list of numbers such that the ithi^\text{th} number is larger than the (2i)th(2i)^\text{th} and (2i+1)th(2i+1)^\text{th} numbers.


True or False?

If I reverse a minimum heap, I always get a maximum heap.

×

Problem Loading...

Note Loading...

Set Loading...