How to check whether an array represents max heap

  • Thread starter Thread starter 22990atinesh
  • Start date Start date
  • Tags Tags
    Array Max Tree
Click For Summary
The discussion centers on whether two specific arrays represent a binary max heap. The arrays in question are 99,98,97,55,49,49,48,13,54 and 99,98,97,55,54,49,49,48,13. Despite attempts to construct tree structures confirming they satisfy max heap properties, the provided answer indicates neither array qualifies as a max heap. The clarity of the problem statement is questioned, suggesting it should specify that it refers to multiple arrays. The ambiguity raises the possibility of a typographical error in the original question.
22990atinesh
Messages
143
Reaction score
1

Homework Statement


Does the following array represents the binary max heap
99,98,97,55,49,49,48,13,54
99,98,97,55,54,49,49,48,13

Homework Equations

The Attempt at a Solution


I've tried to construct the tree structure and all the above array representation satisfies the binary max heap property. But ans is given as no (i.e non of them represents the binary max heap)
 
Physics news on Phys.org
After glancing at the method or representing heaps as arrays and looking up the definition of a max heap, I think your answer is correct (i.e. each array does represent a max heap).

However, the grammer in the statement of the problem is peculiar. I think the problem should say "Do the following arrays represent a binary max heap?". That version is still not clear. It would be clear if it said "For each of the following arrays, tell whether the array represents a binary max heap." Is it possible that there is only supposed to be a single array and that a comma was omitted after "54"?
 

Similar threads

  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 15 ·
Replies
15
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
Replies
5
Views
2K
Replies
3
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K