Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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); 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
Step: 1
c int heapInfoint nums int n Check for maxHeap for int i 0 i n 2 i int leftChild 2 i 1 int rightChil...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started