1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Rooted tree impossible constructs

  1. Apr 14, 2014 #1
    1. The problem statement, all variables and given/known data

    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.

    2. Relevant equations

    3. 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.
     
  2. jcsd
  3. Apr 14, 2014 #2

    mfb

    User Avatar
    2016 Award

    Staff: Mentor

    V=0? Negative values? Non-integer values?
    The full problem statement would help.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted



Similar Discussions: Rooted tree impossible constructs
  1. Binary trees (Replies: 1)

  2. Construction drawing (Replies: 2)

  3. Recursion Tree (Replies: 3)

  4. Parse tree (Replies: 3)

Loading...