Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Only use C++ Method for Binary Search Tree I need Question 2 Solution. only Solve Question no 2. Question No.1 [5 Marks] In this assignment,

image text in transcribed

image text in transcribed

Only use C++ Method for Binary Search Tree

I need Question 2 Solution. only Solve Question no 2.

Question No.1 [5 Marks] In this assignment, you will have to implement the basic functions needed to build and search binary search trees (abbreviated BST). Your implementation should be such that the nodes of the tree contain an integer and links (possibly null) to the left and right children of the node. 1. Binary Search Trees (BSTs) a. Draw the BST where the data value at each node is an integer and the values are entered in the following order: 36,22,10,44,42. b. Draw the BST after the following insertions have been done in the tree of part (a): 16,25,3,23,24 (there is no attempt at being tricky; parts (a) and (b) could be combined into a single one but we want you to check your work so that you don't make a silly mistake). c. Now draw the tree after deletions of 42,23 and 22 in this order. d. Write down the order on which the node values are reached when the BST of part (c) is traversed. (i) in inorder (ii) in postorder (iii) in preorder. e. What is the height of the tree of part (c)? Which nodes have maximal depth in the tree of part (c)? Question No.2 [5 Marks] Programming Assignment In this assignment you have to implement some basic C++ methods for BST's (with a little twist) and an iterator (i.e., a post-order sequencing). Specifically, the methods that you have to implement are: - insertordelete(item). If item is not in the tree, it is inserted in the tree. If item is already in the tree, it is deleted from the tree. - contains(item) returns true if item is in the tree, false otherwise. - size() returns the number of nodes in the tree. This method should run in O(1). - iteratorn returns an iterator for the BST. - print() prints the elements of the tree in in-order. one element per line. In this assignment you have to implement some basic C++ methods for BST's (with a little twist) and an iterator (i.e., a post-order sequencing). Specifically, the methods that you have to implement are: - insertordelete(item). If item is not in the tree, it is inserted in the tree. If item is already in the tree, it is deleted from the tree. - contains(item) returns true if item is in the tree, false otherwise. - size() returns the number of nodes in the tree. This method should run in O(1). - iterator0 returns an iterator for the BST. - print() prints the elements of the tree in in-order. one element per line

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Securing SQL Server Protecting Your Database From Attackers

Authors: Denny Cherry

3rd Edition

0128012757, 978-0128012758

More Books

Students also viewed these Databases questions

Question

distinguish between private and public companies?

Answered: 1 week ago

Question

What lessons in OD contracting does this case represent?

Answered: 1 week ago

Question

Does the code suggest how long data is kept and who has access?

Answered: 1 week ago