2 votes 2 votes Is an array that is sorted in decreasing order a max-heap? always yes always no sometimes only yes but not in presence of duplicates Algorithms go-alogrithms-1 algorithms sorting heap-sort + – Bikram asked Oct 4, 2016 Bikram 643 views answer comment Share Follow See all 0 reply Please log in or register to add a comment.
Best answer 6 votes 6 votes Always Yes Every array which is sorted in ascending order is always a min heap And Every array which is sorted in descending order is always a max heap . Kapil answered Oct 12, 2016 • edited Oct 15, 2016 by Kapil Kapil comment Share Follow See all 5 Comments See all 5 5 Comments reply Show 2 previous comments himshukla007 commented Sep 29, 2017 reply Follow Share i think max sorted in ascending order.....!!!!!!!!check out https://stackoverflow.com/questions/41212072/ascending-and-descending-heapsort 0 votes 0 votes shraddha priya commented Mar 19, 2019 reply Follow Share Why not option D? Root of subtrees of maxheap should be larger than children but in case of duplicate values this will be violated, right? 0 votes 0 votes abhishekmehta4u commented Mar 19, 2019 reply Follow Share @shraddha priya Yes, they can. You can read about this in 'Introduction to Algorithms' (by Charles E. Leiserson, Clifford Stein, Thomas H. Cormen, and Ronald Rivest). According to the definition of binary heaps in Wikipedia: All nodes are either [greater than or equal to](max heaps) or [less than or equal to](min heaps) each of its children, according to a comparison predicate defined for the heap. 2 votes 2 votes Please log in or register to add a comment.
1 votes 1 votes converse of this statement is not always true. every array which is sorted in descending order is Max heap. every heap may not be always sorted in descending order array. e-g - 20 18 12 16 15 10 9 mrinmoyh answered May 17, 2020 mrinmoyh comment Share Follow See all 0 reply Please log in or register to add a comment.
0 votes 0 votes is max heap sorted array in decreasing order or increasing order...???????? himshukla007 answered Sep 29, 2017 himshukla007 comment Share Follow See all 0 reply Please log in or register to add a comment.
0 votes 0 votes An array sorted in ascending order is can be treated as min- heap" and its complementry statement is "An array sorted in descending order can be treated as max heap". Rahul_kumar3 answered Oct 12, 2023 Rahul_kumar3 comment Share Follow See all 0 reply Please log in or register to add a comment.