Create a binary search tree

Assignment Help Data Structure & Algorithms
Reference no: EM13844479

Create a Binary Search Tree,

which supports the following operations. · insert(tree, element) - adds the node specified by element (which contains the data) into the BST specified by tree.

· search(tree, key) - searches for the data specified by key in the BST specified by tree.

· findMin(tree) - retrieves the smallest data in the BST specified by tree. · findMax(tree) - retrieves the largest data in the BST specified by tree. · predecessor(tree, element) - retrieves the inorder-predecessor of the node specified by element in the BST specified by tree. · successor(tree, element) - retrieves the inorder-successor of the node specified by element in the BST specified by tree.

· delete(tree, element) - removes the node specified by element from the BST specified by tree. Input - Output Format The input consists of multiple lines, each one containing either one or two integers. The first integer in the line can be 0, 1, 2, 3, 4, 5, 6, or 7 and each one has its own meaning: · The integer 0 means stop the program.

· The integer 1 means, create a node which contains the next integer from the input as the data part, and then, insert this node into the BST. In this case, the next integer (>= 0) is given on the same line as the 1, separated by a space. CS2094 - Data Structures Laboratory Page 3/7

· The integer 2 means, search for the key specified by the next integer from the input, in the BST. In this case, the next integer (>= 0) is given on the same line as the 2, separated by a space. If the search is successful, output "FOUND". Otherwise, output "NOT FOUND".

· The integer 3 means find and output the minimum number in the BST. Print "NIL" if the BST is empty.

· The integer 4 means find and output the maximum number in the BST. Print "NIL" if the BST is empty.

· The integer 5 means find and output the inorder-predecessor of the data specified by the next integer from the input. In this case, the next integer (>= 0) is given on the same line as the 5, separated by a space. Output "NIL", if the data exists in the tree, but there is no inorder-predecessor for the data. Output "NOT FOUND", if the data is not present in the tree. · The integer 6 means find and output the inorder-successor of the data specified by the next integer from the input. In this case, the next integer (>= 0) is given on the same line as the 6, separated by a space. Output "NIL", if the data exists in the tree, but there is no inorder-successor for the data. Output "NOT FOUND", if the data is not present in the tree. · The integer 7 means delete the data specified by the next integer in the input from the BST, if present. In this case, the next integer (>= 0) is given.

Reference no: EM13844479

Questions Cloud

Summarize the concept of corporate social responsibility : Summarize the concept of corporate social responsibility (CSR). Is it a fad, or is it here to stay? List at least three arguments for CSR and three arguments against CSR
Write a program that implements dijkstras algorithm : Write a program that implements Dijkstra's algorithm
Calculate advanced corporations breakeven point : Calculate Advanced Corporation's breakeven point for 20x5 (i) in units, and (ii) in amount. Calculate Advanced Corporation's breakeven point (i) in units, and (ii) in amount if variable costs are 52% of revenues.
Write a program that implements kruskals algorithm : Write a program that implements Kruskal's algorithm
Create a binary search tree : Create a Binary Search Tree
About preorder or postorder : Traverse this tree in inorder, preorder and postorder fashion (all three methods, both recursively and iteratively)
Proposals to improve the profitability : You have been asked to assess the expected financial impact of each of the following proposals to improve the profitability of credit sales made by your company.  Each proposal is independent of the other.  Answer all questions.  Showing your work..
Ways in which human resources can influence motivation : Observe theories of motivation in your lives and work- What are two ways in which Human Resources can influence motivation within an organization
Find the iteration formula for the secant method : Determine a polynomial function f(x) that has α as its true root - find the iteration formula for the Secant method.

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  Advanced systems analysis and design

Produce a system specification indicating functional and non-functional requirements - Generate suitable prioritised Use Cases for the system.

  Create long queue-customers dequeue to next counter

Write a program to simulate a grocery store checkout counter. Construct one long queue from which customers dequeue to the next available counter.

  Question related to sequential files

In spite of the fact that sequential files lack direct targeted addressing of each of the records and fields, they are the most widely used.

  Design a simple algorithm by giving pseudocode

Design a simple algorithm by giving pseudocode, for constructing a binary search tree T on n elements in O(nlogn) time with the property that any Find operation on T takes O(logn) time.

  Question about character array

The 2-most important design issues that are specific to character string types are the given, Should strings be simply a special kind of character array or a primitive type?

  Survey of fault tolerance policy for load balancing scheme o

This paper investigates about fault-tolerance in load balancing schemes in distributed environment. There are some more parameters influencing QOS but our main focus is on fault tolerance and load balancing.

  Algorithm for string of numbers recognize all the substrings

Write down algorithm, using pseudocode, to perform the following task, Given a string of numbers, recognize all of the substrings that form numbers that are divisible by 3.

  Build a binary search tree

Build a binary search tree using the following set of numbers, preserving the orderin which they are given: 34,26,47,22,28,10,24,38,51,49,37,4,45,60,57,14.

  The warehouses the firm supplies retail outlets

DSS Inc. is an electronics company with production facilities located in Atlanta, Boston, and Chicago. Components produced at these facilities may be shipped to the firm's regional warehouses that are located in Edison and Fargo. From the warehouses ..

  Draw one child diagram using the level 0 diagram

As a systems analyst or knowledgeable end-user, you must learn how to draw data flow diagrams to model business process requirements.

  Question about data model

Create a simple data model that outlines a database management system. This model requires to track people's participation in several fitness activities at a fitness center.

  Part-11describe your choice of application2what elements of

part-11.describe your choice of application?2.what elements of the software or hardware would consider in the

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd