bsc

Comprehensive codebase and cou...
Log | Files | Refs | Activity | README | LICENSE

root / semester_2 / algorithms / algo_051.md

algo_051.md (352B)


      1 # algo_051
      2 
      3 ### Problem Statement
      4 
      5 > Write an algorithm to count the number of leaf nodes in a binary tree.
      6 
      7 ## Algorithm
      8 ```
      9 procedure countLeaf(T)
     10 begin
     11     if (T = NULL) then
     12         return 0;
     13     else if (LC(T) = NULL and RC(T) = NULL) then
     14         return 1;
     15     else
     16         return countLeaf(LC(T)) + countLeaf(RC(T));
     17     endif
     18 end procedure
     19 ```
© notamitgamer • Site Built: 2026-09-05 01:53:16 UTC • git-mirror commit: c170d72 [view raw info]
Originally created with stagit • modified by notamitgamer
Forked from github.com/notamitgamer/git-mirror