edited by
2,610 views
0 votes
0 votes

This question is in CLRS,if we have a max heap it is always in sorted order(descending) order.And by extension if we have min heap the array is sorted in ascending order.Is this true?

I have a counter example for 100,50,20,1,3,10,5,this satisfied max-heap property but is not sorted when represented as an array.

Edit 1: Is it required always Heapify the heap,when we represent it as an array is it an heapified representation or not?

If we heapify after deletion and store max deleted element then we get sorted array.

edited by

1 Answer

0 votes
0 votes
U have interpreted it wrongly....it's only one way.If the array is sorted or reverse sorted it is already a min or max heap respectively not vice versa

Related questions

3 votes
3 votes
1 answer
1
Akriti sood asked Dec 26, 2016
985 views
Consider an array ‘A’ with 2m elements. The elements in odd position are sorted in non-increasing order that is A >= A[3] >= A[5]......A[2m-1] The elements in even p...
0 votes
0 votes
1 answer
2
iarnav asked Jun 12, 2018
840 views
Given an sorted array in descending order, what will be the time complexity to delete the minimum element from this array?
8 votes
8 votes
2 answers
3
1 votes
1 votes
0 answers
4