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

  Implement an open hash table

In this programming assignment you will implement an open hash table and compare the performance of four hash functions using various prime table sizes.

  Use a search tree to find the solution

Explain how will use a search tree to find the solution.

  How to access virtualised applications through unicore

How to access virtualised applications through UNICORE

  Recursive tree algorithms

Write a recursive function to determine if a binary tree is a binary search tree.

  Determine the mean salary as well as the number of salaries

Determine the mean salary as well as the number of salaries.

  Currency conversion development

Currency Conversion Development

  Cloud computing assignment

WSDL service that receives a request for a stock market quote and returns the quote

  Design a gui and implement tic tac toe game in java

Design a GUI and implement Tic Tac Toe game in java

  Recursive implementation of euclids algorithm

Write a recursive implementation of Euclid's algorithm for finding the greatest common divisor (GCD) of two integers

  Data structures for a single algorithm

Data structures for a single algorithm

  Write the selection sort algorithm

Write the selection sort algorithm

  Design of sample and hold amplifiers for 100 msps by using n

The report is divided into four main parts. The introduction about sample, hold amplifier and design, bootstrap switch design followed by simulation results.

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