How to check whether an array represents max heap

  • Thread starter Thread starter 22990atinesh
  • Start date Start date
  • Tags Tags
    Array Max Tree
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
1 replies · 3K views
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)
 
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 grammar 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"?