Rooted tree impossible constructs

  • Thread starter Thread starter spaghetti3451
  • Start date Start date
  • Tags Tags
    Impossible Tree
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
1 reply · 1K views
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