Project 4.pdf - Project 4 S ubmit Assignment ● ● ●...

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

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Project 4 S ubmit Assignment ● ● ● ● ● Due Nov 8 by 11:59pm Points 20 Submitting a file upload File Types zip Available Oct 18 at 6:30pm ­ Dec 13 at 11:59pm about 2 months Directions: PLEASE NOTE: You may not use any STL collection classes when implementing this programming project. You must use the code discussed in class. Please choose the code download which matches your development environment ( B ST Code for VS (Links to an external site.) B ST Code for XCode (Links to an external site.) ). Project 4A : Working With Binary Search Trees Complete the following exercises using the cs20::BST class presented in class. 1. Without using a TreeIterator, create a new method called total that takes an no arguments and determines that the sum of all the elements stored in the BinarySearchTree. If the root of the tree is nullptr, then your method should throw an InvalidTreeArgument exception. The prototype of this method should be: int BST< Object >::total( ) const throw( InvalidTreeArgument ); Because the method has been marked const, your implementation will not be able to change any of the data members found in the BinarySearchTree. Instead, you should use recursion to walk all the nodes in the tree and return the total seen so far in the recursive stack. For example, for the BST shown below: total( ) should return 338 (= 32 + 24 + 41 + 21 + 28 + 36 + 47 + 14 + 25 + 31 + 39) Create a test driver that exercises this new feature, prints the tree and the results of this new operation. 2. Without using a TreeIterator, create a new method called isMatchingTree that takes an BST parameter and determines if this tree has the exact same matching structure as the passed parameter. In other words, the exact same data values need to be found in both trees in the exact same structural arrangement. If the root of the tree is nullptr, your method should throw an InvalidTreeArgument exception. The prototype for this method should be: bool BST< Object >::isMatchingTree( BST< Object > otherTree ) const throw( InvalidTreeArgument ); Because the method has been marked const, your implementation will not be able to change any of the data members found in the BinarySearchTree. Instead, you should use recursion to walk all the nodes in the tree and verify that the same matching element value is found in each node. Create a test driver that exercises this new feature, prints the tree and the results of this new operation. ...
View Full Document

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern