Rooted tree impossible constructs

  • Thread starter Thread starter spaghetti3451
  • Start date Start date
  • Tags Tags
    Impossible Tree
AI Thread Summary
The discussion focuses on constructing a rooted tree with specific constraints: a depth D requiring at least one node exactly D distance from the root and a maximum node degree of V. The participant is attempting to calculate the maximum number of nodes by summing V^i from 0 to D, which seems effective in many scenarios. However, they question the conditions under which the problem might be unsolvable, suggesting that cases like V=0 or negative/non-integer values could lead to a -1 output. Clarification on the full problem statement is needed to address these concerns.
spaghetti3451
Messages
1,311
Reaction score
31

Homework Statement



For a UVa problem, I am working on constructing a rooted tree with the following constraints.

1. A tree of depth D means that the tree should contain at least 1 node which is exactly D distance away from the root and there is no node of more than D distance from the root.

2. The degree of a node of the tree cannot be greater than V . Degree of a node is simply measured by the number of nodes it is directly connected to, via a single edge.

Homework Equations



The Attempt at a Solution



The goal is to determine the maximum possible number of nodes. To find that, I am looking to sum over all V^i , where i ranges from 0 to D. This summation appears to give the maximum number of nodes correctly in many cases, so I'm assuming it's correct.

However, the question also states that 'If it is not possible to construct the tree, print -1'. I can think of no possible case where this might occur. Do you think this is supposed to be be printed when the user enters V and D outside the range given in the problem.
 
Physics news on Phys.org
V=0? Negative values? Non-integer values?
The full problem statement would help.
 
Back
Top