kneedhelp
kneedhelp

Reputation: 675

Binary Tree Leaves

Question: assuming a binary search tree has 5 leaves, what is the minimum number of levels that it could have?

I thought a leaf was a node that did not have any children, and when I approached this problem I got 6 levels, but the answer is 4. Can someone explain this?

My process:

           50
          /  \
         30  Leaf
        /  \
      Leaf 40
          /  \
         35  Leaf
        /  \
       33  Leaf
      /  \
    Leaf  34

I might be doing something wrong visualizing the tree, if that's the case please let me know

Upvotes: 0

Views: 57

Answers (1)

PM 77-1
PM 77-1

Reputation: 13334

There could be nodes with two leaves.

    10
    /\
   21 22
   /\   /\
  L  L 31 L
       /\
      L  L

Upvotes: 1

Related Questions