MAX DIVISOR TREE Let a tree exists with the root value N. The property of this...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
MAX DIVISOR TREE Let a tree exists with the root value N. The property of this tree is that each of its nodes branches out to the nodes with a value equal to one of its divisors (except 1 and the number itself). What maximum height the tree can have? Note: The height of a tree is defined as the number of edges in its longest path from the root to a leaf node. Example Consider N = 8. You must determine the maximum height of the tree under the given conditions: • The root of the tree is 8. It branches out two nodes with values 2 and 4. • Node 4 can again branch out a node with value 2. Therefore the maximum height of the tree is 2. The path looks like this: 8 (~.) • The root of the tree is 8. It branches out two nodes with values 2 and 4. • Node 4 can again branch out a node with value 2. Therefore the maximum height of the tree is 2. The path looks like this: 8 -> 4->2 Function description Complete the solve function provided in the editor. This function takes the following parameter and returns the answer: • N: Represents the root of the tree. Input format Note: This is the input format that you must use to provide custom input (available above the Compile and Test button). • The first line and the only line of input consists of an integer N denoting the root value of the tree. Output: • Output a single integer denoting the MAXIMUM HEIGHT OF THE TREE. Input format Note: This is the input format that you must use to provide custom input (available above the Compile and Test button). • The first line and the only line of input consists of an integer N denoting the root value of the tree. Output: • Output a single integer denoting the MAXIMUM HEIGHT OF THE TREE. Constraints: 1≤N≤ 1000000 Code snippets (also called starter code/bollerplate code) This question has code snippets for C, CPP, Java, and Python. Sample Input 1 10 Copy Sample output 1 1 Copy MAX DIVISOR TREE Let a tree exists with the root value N. The property of this tree is that each of its nodes branches out to the nodes with a value equal to one of its divisors (except 1 and the number itself). What maximum height the tree can have? Note: The height of a tree is defined as the number of edges in its longest path from the root to a leaf node. Example Consider N = 8. You must determine the maximum height of the tree under the given conditions: • The root of the tree is 8. It branches out two nodes with values 2 and 4. • Node 4 can again branch out a node with value 2. Therefore the maximum height of the tree is 2. The path looks like this: 8 (~.) • The root of the tree is 8. It branches out two nodes with values 2 and 4. • Node 4 can again branch out a node with value 2. Therefore the maximum height of the tree is 2. The path looks like this: 8 -> 4->2 Function description Complete the solve function provided in the editor. This function takes the following parameter and returns the answer: • N: Represents the root of the tree. Input format Note: This is the input format that you must use to provide custom input (available above the Compile and Test button). • The first line and the only line of input consists of an integer N denoting the root value of the tree. Output: • Output a single integer denoting the MAXIMUM HEIGHT OF THE TREE. Input format Note: This is the input format that you must use to provide custom input (available above the Compile and Test button). • The first line and the only line of input consists of an integer N denoting the root value of the tree. Output: • Output a single integer denoting the MAXIMUM HEIGHT OF THE TREE. Constraints: 1≤N≤ 1000000 Code snippets (also called starter code/bollerplate code) This question has code snippets for C, CPP, Java, and Python. Sample Input 1 10 Copy Sample output 1 1 Copy
Expert Answer:
Related Book For
Introduction to Algorithms
ISBN: 978-0262033848
3rd edition
Authors: Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest
Posted Date:
Students also viewed these programming questions
-
A major theme of this chapter is that our cognitive processes influence ethical decision making. Use the theme to comment on the following statement, which various religions claim as their own and...
-
One of the messages of this chapter is that while Monte Carlo is a clever method of calculation, it shouldnt be used when some better method exists. The MC valuation of in section 25.2, for example,...
-
The implication of this diagram is that elimination of what structures would prevent or eradicate eyeblink conditioning? Stelioto col Parale foren Besket col Punrje Ceroler cotox Golg Grare ol Musey...
-
A 15.00 g metal sphere was found to have a diameter of 1.85 cm. The volume of a sphere is V = (4/3)r. Calculate the density of the sphere and assuming that the sphere is made out of one of the...
-
On January 1, 2011, Aronsen Company acquired 90 percent of Siedel Company's outstanding shares. Siedel had a net book value on that date of $480,000: common stock ($10 par value) of $200,000 and...
-
Medifast, Inc. is a producer and marketer of weight-loss meals and other health and weight-loss products. The following are selected financial data for the company for the period 2006?2010. a....
-
Spreading rate of spilled liquid. Refer to the Chemical Engineering Progress (Jan. 2005) study of the rate at which a spilled volatile liquid will spread across a surface, presented in Exercise 2.168...
-
A contractor is considering whether to purchase or lease a new machine for his layout site work. Purchasing a new machine will cost $12,000 with a salvage value of $1200 at the end of the machine's...
-
Jeff Inc produces eco friendly products. Following info is the status and operations of the Manufacturing Divison of GreenLink which has a hurdle rate of 4% Divisional indentifiable average assets:...
-
How might one employee coach or train another employee by use of Twitter and text messaging?
-
24 Brief Exercise 15-6 (Static) Sales-type lease; lessor; income statement effects [LO15-3] 2 paints eBook Print References A lease agreement that qualifies as a finance lease calls for annual lease...
-
James A. and Ella R. Polk, ages 70 and 65, respectively, are retired physicians who live at 3319 Taylorcrest Street, Houston, Texas 77079. Their three adult children (Benjamin Polk, Michael Polk, and...
-
I need help solving the following question: - Thank you in advance. On January 1, Year 6, HD Lid., a building supply company, JC Lid., a construction company, and Mr. Saeid, a private investor,...
-
Let X 1 , , X n X 1 , , X n be a random sample from a normal distribution with mean and variance 1. Find the uniformly minimum variance unbiased estimator of 2 2 .2 answers
-
The ledger of Duggan Rental Agency on March 31 of the current year includes the following selected accounts before adjusting entries have been prepared. Debit Credit Prepaid Insurance $3,600 Supplies...
-
1.Using the Excel file Sales transaction find the following15 Marks a.Identify the levels of measurement for each variables b.Construct a cross tabulation to find the number of transactions by...
-
Foreign Debt Explain why The Coca-Cola Company and PepsiCo, Inc. may use foreign debt to finance their operations. Explain the risks involved in using foreign debt to finance operations
-
Arlington Merchants reported the following on its income statement for the fiscal years ending December 31, 2016 and 2015. 2016 2015 Sales $4,857,500 $4,752,900 Cost of goods sold 3,258,950 3,207,000...
-
What is the largest k such that if you can multiply 3 3 matrices using k multiplications (not assuming commutativity of multiplication), then you can multiply n n matrices in time o(n lg 7 )? What...
-
Show that if an algorithm makes at most a constant number of calls to polynomial time subroutines and performs an additional amount of work that also takes polynomial time, then it runs in polynomial...
-
Show that by making a different inductive hypothesis, we can overcome the difficulty with the boundary condition T(1) = 1 for recurrence (4.19) without adjusting the boundary conditions for the...
-
What changes, if any, would you recommend, and why?
-
2. Identify one or more of Unilevers strengths, weaknesses, opportunities, and threats.
-
1. For Samsungs management, is adding a solar and wind power unit a strategic management issue? Explain.
![Mobile App Logo](https://dsd5zvtm8ll6.cloudfront.net/includes/images/mobile/finalLogo.png)
Study smarter with the SolutionInn App