Skip to main content
Lesson 35 - Binary Tree Algorithms
Lesson MenuPreviousNext
  
Counting the Nodes in a Tree page 5 of 8

  1. A standard binary tree algorithm is to count the number of nodes in the tree. Here is a pseudocode version.

    Count left subtree recursively
    Count the current node as one
    Count right subtree recursively 
  2. As you develop the code, consider what base case will terminate the recursion.


Lesson MenuPreviousNext
Contact
 ©ICT 2003, All Rights Reserved.