inclassexercise

inclassexercise - /File".h Binary Tree Functions Student 1...

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.

This note was uploaded on 05/23/2008 for the course CS 2605 taught by Professor Ndbarnette during the Summer '06 term at Virginia Tech.

Ask a homework question - tutors are online