Skip to main content
ICT
Lesson AB30 - Binary Search Trees
 
Main   Previous Next
 

F. Counting the Nodes in a Tree page 8 of 15

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

    • Count the left subtree recursively
    • Count the current node as one
    • Count the right subtree recursively

  2. As you develop the code, consider what base case will terminate the recursion.

 

Main   Previous Next
Contact
 © ICT 2006, All Rights Reserved.