algo_050
Problem Statement
Problem Statement
Write an algorithm to count the number of internal nodes in a binary tree.
Algorithm
procedure countInternal(T)
begin
if (T = NULL) then
return 0;
else if (LC(T) = NULL and RC(T) = NULL) then
return 0;
else
return 1 + countInternal(LC(T)) + countInternal(RC(T));
endif
end procedure1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10