Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

JAVA ONLY

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. 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

Demystifying Databases A Hands On Guide For Database Management

Authors: Shiva Sukula

1st Edition

8170005345, 978-8170005346

More Books

Students also viewed these Databases questions

Question

Different types of Grading?

Answered: 1 week ago

Question

Explain the functions of financial management.

Answered: 1 week ago

Question

HOW MANY TOTAL WORLD WAR?

Answered: 1 week ago

Question

Discuss the scope of financial management.

Answered: 1 week ago