Rooted tree impossible constructs

  • Thread starter Thread starter spaghetti3451
  • Start date Start date
  • Tags Tags
    Impossible Tree
Click For Summary
SUMMARY

The discussion centers on constructing a rooted tree with specific constraints: a maximum depth D and a maximum node degree V. The participant is attempting to calculate the maximum number of nodes using the formula for summation of V^i from i=0 to D. The participant questions the conditions under which it would be impossible to construct such a tree, speculating that invalid inputs like V=0 or negative values may trigger a -1 output. The conversation highlights the importance of understanding the problem constraints to determine valid input ranges.

PREREQUISITES
  • Understanding of tree data structures
  • Knowledge of mathematical summation techniques
  • Familiarity with constraints in algorithm design
  • Basic programming skills to implement tree construction
NEXT STEPS
  • Research tree construction algorithms with constraints
  • Learn about mathematical series and their applications in algorithm analysis
  • Explore error handling in algorithmic problems
  • Study the implications of input validation in programming
USEFUL FOR

Computer science students, algorithm designers, and software developers interested in tree data structures and their constraints.

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.
 

Similar threads

  • · Replies 11 ·
Replies
11
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
Replies
1
Views
2K
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 15 ·
Replies
15
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K