Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

Project: 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.

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.

Attachment:- Assignment.zip

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M92015988

Have any Question?


Related Questions in Computer Engineering

Listen to or read the transcript of this podcast

Listen to (or read the transcript of) this podcast (https://www.stlouisfed.org/education/economic-lowdown-podcast-series/episode-16-elasticity-of-demand) from the Federal Reserve Bank of St. Louis. describe your experien ...

Calculate the thinkness of the monolayer assuming that the

Calculate the thinkness of the monolayer assuming that the volume of the monolayer is 7.39×10-6 mL and diameter of the watch glass is 5 cm.

Question a with respect to huffman coding devise a formula

Question : (a) With respect to Huffman Coding, devise a formula to compute the average compression based on the number of characters in a piece of text, n, and the number of unique characters in its alphabet, m. (b) Does ...

Question critical infrastructures -1discuss cybersecurity

Question: Critical Infrastructures - 1. Discuss cybersecurity policy issues affecting SCADA and ICS systems for Critical Infrastructure services for the public, and compare those issues to the policy issues that affect t ...

We live in kapurkua a small island in the mediterranean

We live in Kapurkua, a small island in the mediterranean between Greece and Spain (no, it doesn't really exist so don't look it up in the map). In the island we produce and consume canoes, latreks (a garment that is comf ...

Question suppose you want to store the following

Question : Suppose you want to store the following information: Student_id Course Mark 111 Maths 78 111 Physics 90 222 Biology 89 333 Physics 60 333 Chemistry 75 1.a Is this table in first normal form? Why or Why Not? 1. ...

A small factory produces two types of toys trucks and

A small factory produces two types of toys: trucks and bicycles. In the manufacturing process two machines are used: the piece maker and the assembler. It takes 2 hours to make the pieces of the bicycles and 1 hour for t ...

Assignment -question 1 - go-back-n in the following network

Assignment - Question 1 - (Go-Back-N) In the following network, node A transmits packets that pass through B and C, and arrive at the destination D. The bit rate of all links is R = 1 Mbit/sec. The maximum packet size in ...

Question using the apple company identify all the social

Question: Using the Apple company, identify all the social media platforms it currently uses. List all the social media platforms. List five different KPI's you could use to measure the engagement on each platform. Expla ...

Question research the options for creating a gui on a sun

Question : Research the options for creating a GUI on a Sun Solaris platform that can be duplicated on a Windows platform. Select a tool for creating a dual platform product and specify how much time would be needed for ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As