Heap

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

  • the \(1^\text{st}\) number is smaller than the \(2^\text{nd}\) and \(3^\text{rd}\) numbers;
  • the \(2^\text{nd}\) number is smaller than the \(4^\text{th}\) and \(5^\text{th}\) numbers;
  • the \(3^\text{rd}\) number is smaller than the \(6^\text{th}\) and \(7^\text{th}\) numbers.

Conversely, a maximum heap is a list of numbers such that the \(i^\text{th}\) number is larger than the \((2i)^\text{th}\) and \((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...