You are given a method's code for a Binary Tree code below. Assume that the methods...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
You are given a method's code for a Binary Tree code below. Assume that the methods and variables are defined and declared in some other part of the program, and they are all compiled and working. Line numbers of the code below are given on the left. 1. template<class ItemType> 2. auto BinaryNodeTree<ItemType> :: balancedAdd( std::shared_ptr<BinaryNode <ItemType>> subTreePtr, 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. { if (subTreePtr == nullptr) return newNodePtr; else { 23. } 24. } std::shared_ptr<BinaryNode<ItemType>> newNodePtr) auto leftPtr = subTreePtr->getLeftChildPtr(); auto rightPtr = subTreePtr->getRightChildPtr(); if (getHeightHelper (leftPtr) > getHeightHelper (rightPtr)) { rightPtr = balancedAdd(rightPtr, newNodePtr); subTreePtr->setRightChildPtr (rightPtr ); } else { leftPtr = balancedAdd(leftPtr, newNodePtr); sub TreePtr->setLeftChildPtr(leftptr); } return subTreePtr; A. Q.1.a. (10 pts) What does this code mean to you? State your idea esp. mentioning the lines 1-2, 4-5, 11-19 G and 22. You are given a method's code for a Binary Tree code below. Assume that the methods and variables are defined and declared in some other part of the program, and they are all compiled and working. Line numbers of the code below are given on the left. 1. template<class ItemType> 2. auto BinaryNodeTree<ItemType> :: balancedAdd( std::shared_ptr<BinaryNode <ItemType>> subTreePtr, 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. { if (subTreePtr == nullptr) return newNodePtr; else { 23. } 24. } std::shared_ptr<BinaryNode<ItemType>> newNodePtr) auto leftPtr = subTreePtr->getLeftChildPtr(); auto rightPtr = subTreePtr->getRightChildPtr(); if (getHeightHelper (leftPtr) > getHeightHelper (rightPtr)) { rightPtr = balancedAdd(rightPtr, newNodePtr); subTreePtr->setRightChildPtr (rightPtr ); } else { leftPtr = balancedAdd(leftPtr, newNodePtr); sub TreePtr->setLeftChildPtr(leftptr); } return subTreePtr; A. Q.1.a. (10 pts) What does this code mean to you? State your idea esp. mentioning the lines 1-2, 4-5, 11-19 G and 22.
Expert Answer:
Answer rating: 100% (QA)
The provided code appears to be part of a binary tree implementation specifically the balancedAdd method in the BinaryNodeTree class Heres an explanat... View the full answer
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
(20 points)Write a program that prompts the user to input five decimal numbers. The program should then add the five decimal numbers, convert the sum to the nearest integer, and print the result....
-
It is initially at 25\deg C. The warehouse is desired to be cooled to 5\deg C. The heat transferred from the external environment to the tank is 1.2 kW. Accordingly, a cooling system with H kW power...
-
Which one of the following is NOT an example of cash flows in operating activities according to direct method? Select one: a. Cash payment for purchase of inventories b. Cash received from debtors c....
-
A bridge hand contains 13 cards. (a) What percent of bridge hands contain all four aces? (b) What percent of bridge hands contain the two red kings, the two red queens, and no other kings or queens?...
-
Replace the loading acting on the frame by an equivalent resultant force and couple moment acting at point B. 80 lb + -3 ft- B -3 ft- 75 lb 60 lb + -3 ft- -3 ft- 2 ft + 40 lb A 4 ft
-
Two small, irregularly shaped conducting objects, one carrying charge \(+q\) and one carrying charge \(-q\), are placed on an \(x\) axis at \(x=-4.0 \mathrm{~m}\) and \(x=+4.0 \mathrm{~m}\),...
-
Presented below is information related to Zonker Company. 1. On July 6, Zonker Company acquired the plant assets of Doonesbury Company, which had discontinued operations. The appraised value of the...
-
4 16. The mean and variance of a binomial distribution area and respectively. If P(X = 1) = then P(X = 4 or 5) is equal to: 243 (a) 1/159 64 (b) $ 16 (c) 81 925 145 (d) 27 243 17. Let E1, E2, E3 be...
-
The information listed below refers to the employees of Lemonica Company for the year ended December 31, 2016. The wages are separated into the quarters in which they were paid to the individual...
-
The Internal Revenue Service is auditing the tip income of waiters and waitresses at the Truckee Diner, home of excellent hamburgers and milkshakes. The revenue agent discovers that Maggie, who earns...
-
Human Development/Life Span Group Presentation Each Group will choose a segment of the human life span that is particularly interesting to them: Adolescence (13 years through about 17 years). Based...
-
In December 2015, Joan Jett bought the candy store known as "Sweet Dreams" from Molly Cass. Sweet Dreams was located on 5 th Street in Sunnyville. As part of the contract, Molly Cass was not...
-
The purchases journal for Rodman Company is shown below. Date December 1 December 7 December 22 December 31 Date Name Date Jim Danta Tom Tome Sue Wasco Purchases Show how the amounts would be posted...
-
PetValue, Inc. has 100,000 shares outstanding and seven directors. 1. What number constitutes a quorum of shareholders? 2. What number constitutes a quorum of directors? 3. If six directors are...
-
1. Draw a schematic of the process with annotations indicating the relevant inlet/outlet along with heat/work considerations. 2. Define a system and perform an energy balance to obtain an expression...
-
You are a budget analyst in the Budget Office of the City of Northville. Mayor Spark just asked you to "run some numbers" so that she can take a look at the arrangement that was just negotiated...
-
Coastal Refining Company operates a refinery with a distillation capacity of 12,000 barrels per day. As a new member of Coastal's management team, you have been given the task of developing a...
-
Larry Gaines, age 42, sells his personal residence on November 12, 2012, for $144,000. He lived in the house for 7 years. The expenses of the sale are $10,500, and he has made capital improvements of...
-
Diane is a single taxpayer who qualifies for the earned income credit. Diane has two qualifying children who are 3 and 5 years old. During 2012, Diane's wages are $17,100 and she receives dividend...
-
Ann hires a nanny to watch her two children while she works at a local hospital. She pays the 19-year-old nanny $125 per week for 48 weeks during the current year. a. What is the employer's portion...
-
Brown India Limited manufactures office tables. Normal capacity of the factory is 60,000 tables per annum. Following are the cost and inventory details for the year 200506. Required: Carry out the...
-
Shoppers Departmental Stores Ltd. furnishes the following details of purchase, sale etc. of its garments section for the year 200506. Determine the value of inventory of the garments section as on...
-
KABU Enterprises Ltd. buys a building for the purpose of investment. It issues 1,00,000 equity shares of its company, which are quoted on the day of the deal at Rs. 155 per share at the NSE. The...
Study smarter with the SolutionInn App