6 kyu

The Strongest Tree in the Forest

Description:

You have a class called Node, representing a node in a binary tree (https://en.wikipedia.org/wiki/Binary_tree).

Each node has 2 children - the right child and the left child. These children can of course be null.

You job is to add an instance method, height, which returns the longest branch steming from the tree (starting from this node). For example, this tree would result in 3:

        (Node)
        /    \
    (Node)  (Node)
    /          \
  (Node)      (Node)
       \
      (Node)
      

Recursion is not necessary, but highly recommended.

Fundamentals
Algorithms
Recursion

Stats:

CreatedDec 27, 2017
PublishedDec 27, 2017
Warriors Trained207
Total Skips25
Total Code Submissions268
Total Times Completed90
Ruby Completions90
Total Stars4
% of votes with a positive feedback rating85% of 27
Total "Very Satisfied" Votes19
Total "Somewhat Satisfied" Votes8
Total "Not Satisfied" Votes0
Total Rank Assessments7
Average Assessed Rank
6 kyu
Highest Assessed Rank
6 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • Abbabon Avatar
  • Unihedron Avatar
  • seasidetesting Avatar
Ad