Possible issue with Max Heap challenge?

Hello! I am in the Coding Interview Prep section. I passed the challenge Insert an Element into a Max Heap. However, when I test it myself, I don’t think it’s working properly. I will provide my code later if needed, but I just want to make sure I understand max heaps.
The following doesn’t satisfy the heap property, correct?
[ null, 45, 50, 35, 30, 20, 15 ]
Because 50 > 45 and 45 is its parent. However, this is a result when testing my code. But my code still passes.

Or am I misunderstanding max heaps?
Many thanks. :slight_smile:

1 Like

Something indeed looks wonky. Mentioned relation between parent and child is one thing. Another is that, in max heap, the first element after the null should be always the biggest element. Otherwise the condition for removing elements in order also won’t be met.

1 Like

That’s what I thought. I will follow the protocol for reporting this and see if there’s a bug, because my code shouldn’t pass. Thanks!