Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A)Please print- positive key sum B)pint- tree that deleted the maximum element not the min C)print tree in decreasing order D)Print post order .You can

image text in transcribed
A)Please print- positive key sum
B)pint- tree that deleted the maximum element not the min
C)print tree in decreasing order
D)Print post order
image text in transcribed
.You can use the array of the previous example to test your program, however, I suggest that you also use other input arrays to validate the correctness and efficiency of your solution. Your program MUST be submitted only in source code form (.Java file) A program that does not compile or does not run loses all correctness points. In this problem, you will write some Java code for simple operations on binary search trees where keys are integers. Assume you already have the following code and assume that method bodies, even though not shown, are correct and implement the operations as we defined them in class. the public class BinarySearchTreeNode public int key; public BinarySearchTreeNode left public BinarySearchTreeNode right; public class BinarysearchTre private BinarysearchTreeNode root; public void insert(int key)C public void delete(int key) (... public boolean find (int key) (a) Add a method public int positiveKeySum() to the BinarySearchTree class that returns the sum of all non-negative keys in the tree. You will need an assistant/helper method. (b) Add method public void deleteMax() to the BinarySearchTree class that deletes the maximum element in the tree (or does nothing if the tree has no elements). c) Add method public void printTree() to the BinarySearchTree class that iterates over the nodes to print then in decreasing order. So the tree... 1' Produces the output "5 4321 COP3530 Spring 2019 RVC A2.pdt (page 4 of 4) Q Search Note: You will need an assistant/helper method. d) Add method public void printPostorder() to the BinarySearchTree class that prints out the nodes of the tree according to a "postorder" traversal. So the tree... 4 Produces the output "1 3 25 4" Note: You will need an assistant/helper method. e) You have a binary search tree. Consider a leave /. B is the set of keys in the path p of / including the leave and the root of the tree. A is the set of keys to the left of the path p. C is the set of keys to the right of the path p. Is the following statement true or false? Given any element a in A; b in B; c in C; a sb s c. Justify your answer. Important Notes: .For this problem, you only need to submit the implementation of four methods in Java (positiveKeySum, deleteMin, printTree, and printPostorder) In the part e), you don't need to submit any implementation in Java and just you must answer the

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_2

Step: 3

blur-text-image_3

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

Database Processing

Authors: David M. Kroenke

12th Edition International Edition

1292023422, 978-1292023427

More Books

Students also viewed these Databases questions

Question

1 5 . 3 troubleshoot system

Answered: 1 week ago

Question

6. Explain the power of labels.

Answered: 1 week ago

Question

10. Discuss the complexities of language policies.

Answered: 1 week ago