Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

2 WRITE A PROGRAM AS REQUIRED BELOW. (60 PTS) You are asked to implement a binary search tree class named MyBinary Tree that satisfies the

image text in transcribed

2 WRITE A PROGRAM AS REQUIRED BELOW. (60 PTS) You are asked to implement a binary search tree class named MyBinary Tree that satisfies the following requirements: 1. It will use the following class as the binary tree node. class BTNode { int key; BTNode parent; BTNode left; BTNode right; 2. It should contain but not limited to the following methods: void add(int newNum) // This method will add a new integer number into the binary search tree. boolean delete(int delNum) // Delete the number delNum if it exists. Return true if succeeds and or return false if the number does not exist. boolean contains (int num) // Check whether the tree contains the number num or not. String inOrder() // Return the inorder traversal result (numbers are separated by spaces) String preOrder() // Return the preorder traversal result (numbers are separated by spaces) String postOrder() // Return the postorder traversal result (numbers are separated by spaces) 3. It should have a main method that reads a sequence of numbers from the terminal and print the sorted results. For example: >java MyBinaryTree 5 10 7 101 421 21 9998 -65 -65 15 7 10 21 42 101 9998 4. *Note that the BST tree should be able to handle duplicated keys. When you delete a key you should delete all nodes matching the key

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

Step: 3

blur-text-image

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

Online Market Research Cost Effective Searching Of The Internet And Online Databases

Authors: John F. Lescher

1st Edition

0201489295, 978-0201489293

More Books

Students also viewed these Databases questions

Question

Between 1% to 3% of infants and toddlers meet criteria for GDD.

Answered: 1 week ago

Question

1. Identify and control your anxieties

Answered: 1 week ago