Qn 3: (10 points) The following algorithm seeks to compute the number of leaves in a binary tree. ALGORITHM Leaf Counter
Posted: Fri Jul 01, 2022 5:46 am
Qn 3: (10 points) The following algorithm seeks to compute the number of leaves in a binary tree. ALGORITHM Leaf Counter (T) //Computes recursively the number of leaves in a binary tree //Input: A binary tree T //Output: The number of leaves in T if T = Ø return 0 else return LeafCounter (Tieft)+ LeafCounter (Tright) Is this algorithm correct? If it is, prove it; if it is not, make an appropriate correction.