Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
statisticsBST
#1
Just to make sure I am understanding the specs correctly, how should the following behave when calling statisticsBST?

                            16
                         /        \
                   15               27
                 /                 /      \
             12               25         29
           /     \            /
        9         14     23
      /          /        /   \
    1        13      20     24
  /
0

should statisticsBST on t result in:
Nodes: 14
Minimum depth: 1
Maximum depth: 5

or:
Nodes: 14
Minimum depth: 2
Maximum depth: 6

Note here that the node that gives minimum depth has value of 15 since it's right child is null, and 0 has the maximum depth since it is the furthest node from the root with a null child. I'm just curious if we're effectively counting the number of edges or the number of vertices we visit.
Reply
#2
I believe the root should have a depth of 0 (so that's the minimum depth) and you would count upwards from there.

EDIT: nevermind, misunderstood your question
Reply
#3
I believe the output would be

Nodes: 14
Minimum depth: 2
Maximum depth: 5

The function counts the number of steps to a leaf, not the number of levels. 15 is not a leaf.
Reply
#4
(02-14-2018, 11:31 PM)NiceHam Wrote: I believe the output would be

Nodes: 14
Minimum depth: 2
Maximum depth: 5

The function counts the number of steps to a leaf, not the number of levels. 15 is not a leaf.

Okay but the specs say this: "The minimum depth of a tree is the minimum number of steps from the root to a node with a null child. The maximum depth is similar." So wouldn't 15 technically fit this qualification?
Reply
#5
Yes, 15 has a null child and it took one step to get there from the root.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)