Question: MAX DIVISOR TREE Let a tree exists with the root value N. The property of this tree is that each of its nodes branches

MAX DIVISOR TREE Let a tree exists with the root value N.The property of this tree is that each of its nodes branchesout to the nodes with a value equal to one of its

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: 1N 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

Step by Step Solution

3.40 Rating (156 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!

Related Book