Computer Science, asked by saichakri16171, 1 year ago

Write a method called countbranches that could be added to the inttree class and that returns the total number of branch nodes in the tree. A branch node is any node that is not a leaf node. (hint: look at the code for countleaves written in section 17.3.)

Answers

Answered by Amethystgirl
0

Answer:

getLeafCount(node) 1) If node is NULL then return 0. 2) Else If left and right child nodes are NULL return 1. 3) Else recursively calculate leaf count of the tree using below formula. Leaf count of a tree = Leaf count of left subtree + Leaf count of right subtree.

Similar questions