Answered step by step
Verified Expert Solution
Link Copied!

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);

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... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

An Introduction to Programming with C++

Authors: Diane Zak

8th edition

978-1285860114

More Books

Students also viewed these Programming questions

Question

36. Let p0 = P{X = 0} and suppose that 0 Answered: 1 week ago

Answered: 1 week ago

Question

1. What does dorsal mean, and what is its oppositepg99

Answered: 1 week ago