inclassexercise

inclassexercise - /File:...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
//File: "BinTreeImplementation.h" // Binary Tree Functions // // Student 1: // // Student 2: // // Exercise 5.8 - Leaf node count template <class Key> int BinTree<Key>::numLeafNodes() { return leafNodesHelper(root); } template <class Key> int BinTree<Key>::leafNodesHelper( BinNode* myNode ) { { return 1; } { return leafNodesHelper( myNode->left ) + leafNodesHelper( myNode->right ); } else if ( myNode->left != 0 ) { return leafNodesHelper( myNode->left ); } // myNode->right != 0 else { return leafNodesHelper( myNode->right );
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.
Ask a homework question - tutors are online