Write the definition of function named heapInfo with the prototype below: int heapInfo(int nums[], int n);...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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. 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.
Expert Answer:
Answer rating: 100% (QA)
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 the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
In this assignment, you will create a program that allows theuser to draw in a window using brushes of different sizes andcolors. The user will be able to change the size and color of thebrush using...
-
In Exercises 3336, use possible symmetry to determine whether each graph is the graph of an even function, an odd function, or a function that is neither even nor odd. ------ -2, y CI (0,4) 2 14...
-
Visit www.thephelpsgroup.com and click on the "Our Work" tab at the top. In the Work Portfolio, compare the IMC for the different companies. What were the goals of the integrated marketing campaign?...
-
HA acquired 100 per cent of SBs equity shares on 1 April 20X0 for $185,000. The values of SBs assets at that date were: On 1 April 20X0, all other assets and liabilities had a fair value...
-
All of the following statements are true except a. Correlation is a statistical measure that indicates the strength and direction of the relationship between two variables. b. A positive correlation...
-
Presented below are a number of balance sheet accounts of Cunningham, Inc. (a) Investment in Preferred Stock. (b) Treasury Stock. (c) Common Stock. (d) Dividends Payable. (e) Accumulated...
-
Step 2: Smooth Sailing 1. Edit the sshd_config file. [Your bash commands here]
-
John Fuji (birthdate June 6, 1981) received the following Form W-2 from his employer related to his job as a manager at a Washington apple-processing plant: Johns other income includes interest on a...
-
Excel has a square root function, but not an "nth root" functionso, how can you use Excel to find the (n - 3) root of x? A. It cannot be done in Excel B. Rename your hand-held math calculator "Excel"...
-
What are the implications of transformational leadership for talent development and succession planning, particularly in cultivating a pipeline of future leaders capable of driving organizational...
-
How do you think the nfl can reposition itself in the minds of female consumers? List and explain 2 solutions.
-
It is now January 1, 2014. Last year ABC Company experienced major operational problems which affected the company's financial condition, forcing management to temporarily suspend dividend payments....
-
How does the concept of servant leadership intersect with transformational leadership principles, and what synergies exist between these approaches in driving organizational excellence and societal...
-
Does increased volatility help short calls? short puts? Explain your reasoning in words. Give at least 2 reasons.
-
3) Water enter the boiler in a steam power plant at a rate of 2kg/s, a velocity of 12m/s and an enthalpy of 650 KI/Kg where it absorbs 1850 KI/Kg. the water Turbine transform into steam, enter the...
-
Given that all the choices are true, which one concludes the paragraph with a precise and detailed description that relates to the main topic of the essay? A. NO CHANGE B. Decades, X-ray C. Decades...
-
If necessary, create a new project named TryThis18 Project and save it in the Cpp8\Chap11 folder. Enter the C++ instructions shown earlier in Figure 11-23 into a source file named TryThis18.cpp....
-
Complete a desk-check table for the code shown in Figure 7-48. What will the code display on the computer screen? What value stops the loop? int num = 6; while (num >= 0) { cout > Figure 7-48
-
In this exercise, you will modify the program that you created in Chapter 6s Lab 6-2. If necessary, create a new project named Intermediate21 Project, and save it in the Cpp8\Chap09 folder. Copy the...
-
See Table 2.5 showing financial statement data and stock price data for Mydeco Corp. a. Compute Mydecos PE ratio each year from 2019 to 2023. In which year was it the highest? b. What was Mydecos...
-
See Table 2.5 showing financial statement data and stock price data for Mydeco Corp. a. Compute Mydecos ROE each year from 2019 to 2023. b. Compute Mydecos ROA each year from 2019 to 2023. c. Which...
-
In early 2018, United Airlines (UAL) had a market capitalization of \($25.14\) billion, debt of \($12.73\) billion, and cash of \($5.59\) billion. United also had annual revenues of \($38.72\)...
Study smarter with the SolutionInn App