Consider Tree-Delete (page 298, and also copied below). TREE-DELETE (T, z) 1 if z.left == NIL...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Consider Tree-Delete (page 298, and also copied below). TREE-DELETE (T, z) 1 if z.left == NIL 2 3 4 5 6 7 8 9 10 11 12 13 TRANSPLANT (T, z, z.right) else if z.right == NIL TRANSPLANT (T, z, z.left) else y = TREE-MINIMUM (z.right) // successor if y.p != z TRANSPLANT (T, y, y.right) y.right z.right y.right.p = y TRANSPLANT (T, z, y) y.left - 2.left y.left.p = y = (a) How does this code rely on the Lemma you proved in problem #4? Answer It takes advantage of using the successor to transplant nodes and subtrees upon deletion with the validity of the Lemma. | (b) When node z has two children, we arbitrarily decided to replace it with its successor. We could just as well replace it with its predecessor. (Some have argued that if we choose randomly between the two options we will get more balanced trees.) Rewrite TREE-DELETE to use the predecessor rather than the successor. Modify the above code just as you need to and underline or boldface the changed portions. Consider Tree-Delete (page 298, and also copied below). TREE-DELETE (T, z) 1 if z.left == NIL 2 3 4 5 6 7 8 9 10 11 12 13 TRANSPLANT (T, z, z.right) else if z.right == NIL TRANSPLANT (T, z, z.left) else y = TREE-MINIMUM (z.right) // successor if y.p != z TRANSPLANT (T, y, y.right) y.right z.right y.right.p = y TRANSPLANT (T, z, y) y.left - 2.left y.left.p = y = (a) How does this code rely on the Lemma you proved in problem #4? Answer It takes advantage of using the successor to transplant nodes and subtrees upon deletion with the validity of the Lemma. | (b) When node z has two children, we arbitrarily decided to replace it with its successor. We could just as well replace it with its predecessor. (Some have argued that if we choose randomly between the two options we will get more balanced trees.) Rewrite TREE-DELETE to use the predecessor rather than the successor. Modify the above code just as you need to and underline or boldface the changed portions.
Expert Answer:
Answer rating: 100% (QA)
It seems there might be a formatting issue with the code provided for TREEDELETE making it a bit dif... 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
-
You quit your job where you earned a year to start your own widget business. To start your business, you cashed in your investments of which earned you a year in interest. In the first year, you sold...
-
If the focal length of a lens is 3 centimeters and the image distance is 5 centimeters from the lens, what is the distance from the object to the lens?
-
The company has a conventional costing system in which manufacturing overhead is applied to units based on direct labor-hours. Data concerning manufacturing overhead and direct labor-hours for the...
-
Education is a very important job because it can change and shape people's lives. It gives people the knowledge, skills, and attitudes they need to be successful in their personal and work lives. As...
-
Draw the shear and moment diagrams for the beam. Given: L = 20 ft w = 250lb/ft M1 = 150 lb ft M2 = 150 lb ft ,
-
Mr. Miles obtained a fully amortizing loan of $800,000 at 4% p.a. for 25 years. After 5 years, interest rates have dropped, so that a fully amortizing 20-year loan can be obtained at 3.5% p.a. If the...
-
Two-Way Analysis of Variance. Suppose that two different sets of treatments are of interest. Let \(y_{i j k}\) be the \(k\) th observation level \(i\) of the first treatment type and level \(j\) of...
-
When honeybees are looking for a new home, they send out scouts to explore options. When a scout returns, she does a waggle dance with multiple circuit repetitions to tell the swarm about the option...
-
The group project will involve students working in groups to develop a new social innovation for their own start-up business that addresses a well-defined social problem or contributes to a clear...
-
Refer to the Racquetball Racket case. Review the problem statement and influence chart that were generated for this case in conjunction with the corresponding exercises in Chapter 2. (If this has not...
-
You are given the following information about a group of policies: Claim Payment Policy Limit 50 50 5 15 60 100 500 500 Determine the likelihood function. 100 100 500 1000
-
Prepare the Investment Objectives section of Patels IPS. Patel has been working with Zik for 10 years. At the beginning of the 10-year period, Zik forecasted that the equities in Patels portfolio...
-
Identify two strategies Delgado should use to earn a positive roll yield. Describe the specific steps needed to execute each strategy. Rosario Delgado is an investment manager in Spain. Delgados...
-
Calculate the net cash flow (in euros) to maintain the desired hedge. Show your calculations. With the US dollar currently trading at a forward premium and US interest rates lower than Spanish rates,...
-
Relative to Heydons existing fund, the new fund will most likely: A. hold a smaller number of stocks. B. rebalance at more regular intervals. C. see risk at the company level rather than the...
-
In a research program on human health risk from recreational contact with water contaminated with pathogenic microbiological material, the National Institute of Water and Atmospheric Research (NIWA)...
-
A rocket is launched upward with an initial speed of 325f(t)/(s). Its path is modeled by the equation h=-16t^(2)+325t, where h is the height of the rocket and t is the time in seconds since it...
-
You are standing at x = 9.0 km and your assistant is standing at x = 3.0 km. Lightning bolt 1 strikes at x = 0 km and lightning bolt 2 strikes at x = 12.0 km. You see the flash from bolt 2 at t = 10...
-
Professor Patricia (Patty) Pate is retired from the PalmSprings Culinary Arts Academy (PSCAA). She is a single taxpayer and is 68 years old. Patty lives at 98 Colander Street, Henderson, NV 89052....
-
Jenny earns $34,500 in 2012. Calculate the FICA tax that must be paid by: Jenny: ..............................Soc,Sec. ..................$______________...
-
Olive Corporation was formed and began operations on January 1, 2012. The corporation's income statement for the year and the balance sheet at year-end are presented below. The corporation made...
-
(a) Among 880 smart phones sold by a retailer, 72 required repairs under the warranty. Estimate the probability that a new phone, which has just been sold, will require repairs under the warranty....
-
A car rental agency has 19 compact cars and 12 intermediate-size cars. If four of the cars are randomly selected for a safety check, what is the probability of getting two of each kind?
-
With reference to Exercise 3.34, suppose that the questionnaire filled in by one of the 150 persons is to be double-checked. If it is chosen in such a way that each questionnaire has a probability of...
Study smarter with the SolutionInn App