(5/5)

# Write two find methods that takes one int parameter, which will be the value to search for. The method returns a pointer to the node containing the value if the value is found

INSTRUCTIONS TO CANDIDATES

Programming Assignment 2

Create the BST below by inserting nodes in the correct order to give the tree structure below:

Write two find methods that takes one int parameter, which will be the value to search for. The method returns a pointer to the node containing the value if the value is found, and returns a null pointer otherwise.

One method, find1, will use iteration (not recursion).

The second method, find2, will call a private helper method also named find2 that takes two parameters, the int to search for, and the root node of a sub-tree to search in. The private method will be recursive.

Make the methods print what they are doing as follows:

If the current node is null, print 'Not Found', if the value is found at the current node, print 'Found', if the current node contains a value not equal to the value searched for, print the value at the current node, and print 'Searching Left' or 'Searching Right', depending on which sub-tree the function will look in next.

For example, for the tree diagrammed above, t.find1(30); should print:

40 Searching Left

20 Searching Right Found

(5/5)

## Related Questions

##### . Introgramming & Unix Fall 2018, CRN 44882, Oakland University Homework Assignment 6 - Using Arrays and Functions in C

DescriptionIn this final assignment, the students will demonstrate their ability to apply two ma

##### . The standard path finding involves finding the (shortest) path from an origin to a destination, typically on a map. This is an

Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t

##### . Develop a program to emulate a purchase transaction at a retail store. This program will have two classes, a LineItem class and a Transaction class. The LineItem class will represent an individual

Develop a program to emulate a purchase transaction at a retail store. Thisprogram will have two classes, a LineItem class and a Transaction class. Th

##### . SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 1 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

##### . Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

Hire Me

Hire Me