Please read the instructions carefully, thanks!
Programming/ Coding language: Java
Write a method for a Max–Heap that checks if a given heap is in
heap order (max- heap).
The method shall return true if the heap is in heap-order, false
otherwise.
ANSWER:
To check whether a given Heap is in the order of max heap, we first need to check root if its greater then all of its descendants. Thenn we need to check the children of the root. The java code is given below-
If you are satisfied by my answer please give a thumbs up. Thank you.
Get Answers For Free
Most questions answered within 1 hours.