Question: Write the definition of function named heapInfo with the prototype below: int heapInfo(int nums[], int n); with n representing the length of the array

Write the definition of function named heapInfo with the prototype below: int heapInfo(int nums[], int n);

Write the definition of function named heapInfo with the prototype below: int heapInfo(int nums[], int n); with n representing the length of the array nums. The function returns an int with value 1 if the array represents a maxheap, value 2 if the array does not represent a maxheap but does represent a minheap. value 3 if the tree represented is not a heap (either kind) but does have every leaf with a value greater than or equal to the root value (nums[0]). value 4 in any other case. Remember: The left child of the "node" at index i is at index 2i+1 and the right child is at index 2i+2. If one or both of those indexes has value greater than or equal to n then the corresponding child doesn't exist. A node with no children is a leaf. The root of the tree is just element 0.

Step by Step Solution

3.38 Rating (164 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

c int heapInfoint nums int n Check for maxHeap for int i 0 i n 2 i int leftChild 2 i 1 int rightChil... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!