Create a binary search tree class

Assignment Help Data Structure & Algorithms
Reference no: EM131596772

Advanced Structured Programming and Algorithms

A Binary Search Tree (BST) for a set of input can have many different forms, and the structure of the tree you get depends on the sequence of data from the input array.

The tree is built by calling the treeInsert method on each of the item you encounter in the array. For example, if your input array is
A = {10, 8,2,5}

Then, you would call treeInsert(T,10), treeInsert(T, 8), treeInsert(T, 2), and treeInsert(T, 5). This should place all the elements in the proper position in the BST.

NOTE: You MUST use the pseudocodes given in the class to develop your program (i.e., No Googling and copying codes from a ready-made BST program. They might do it in some different ways).

1. Create a class called Node. This class should have the followings:
- A data member to hold a key that is an int value
- It has data members that point to parent, left, and right nodes
- A constructor that takes the key value

2. Create a binary search tree class. This class should have the followings:
- A data member that points to the root node of the tree
- A constructor that takes an int[] array as argument and build the BST from the array (each node is an object created from class Node in problem 1)
- An iterativeSearch method that can be used to search for a node with the given key value
- A insert method to insert a node into the tree
- A successor method that finds the successor for a given node
- A minimum method that finds the minimum value in any of the subtrees, given a node x (not just from the root and not just the minimum of the entire input array)
- An inorderTreeWalk method that can be used to display the results from the in-order tree walk, starting from any given node

3. Add the main method inside of the binary search tree class to test your codes. Your tests should do the followings:
- Use the input array A = {15, 6, 18, 3, 7, 17, 20, 2, 4, 12, 8}
- Build the binary search tree for this input
- Do the inorderTreeWalk to display the results (this should show the sorted list)
- Use the minimum method to find the minimum, starting from the node with key = 18
- Find the successor to the root node, and display the result on the screen
- Find the successor to node with key = 12, and display the result on the screen The output from running the program should display on the screen as follows:

Inorder tree walk: 2 3 4 6 7 8 12 15 17 18 20
Minimum from node.key = 18 is [the result] Successor to the root node is [the result] Successor to the node.key = 12 is [the result]

Reference no: EM131596772

Questions Cloud

Discuss the electronic medical record technology : Develop a 5- to 7-slide presentation that addresses the requirements for a project governance board investigating the feasibility.
Write the output to a file with that user-supplied name : Create a program called CalcWeightedAvgWithExceptions, and use try-catch-finally blocks - write the output to a file with that user-supplied name
What is the amount of the first year''s interest payment : On January 1, Bank, Rupp & Baroque, Inc. issued $50,000 worth of 10minus -year, 9% bonds for $48,890. What is the amount of the first year's interest payment
Discuss environmental management as a competitive advantage : Discussion: Sustainable Development and the Environment. In a blog post to key stakeholders, discuss using environmental management as a competitive advantage.
Create a binary search tree class : CS501 - Advanced Structured Programming and Algorithms Homework - Create a binary search tree class and You MUST use the pseudocodes given in the class
How much cash dividend was paid to preferred shareholders : Out of Africa, a multi-national corporation had a very successful year. How much of the cash dividend was paid to the PREFERRED shareholders
Create a display of the career information : Provide other information such as; job advancement, outlook, earnings, and other interesting facts about the career.
A wellness plan for the adolescent adult client : A wellness plan for the adolescent/young adult client, using the three nursing diagnoses you have identified.
Write a research paper of toyota motor company : Write a 16 page Research Paper of Toyota Motor Company. Action Planning: This specifies objectives, responsibilities and timelines for completion of objectives.

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