Discuss why we need to balance Binary Search Trees (BSTs)

Requirements: implement methods for the following BST operations: search, insert, tree-traversal (pre, in, and post orders), count (leaves, internal nodes), height.
Approach: Generate a BST by repeatedly inserting at least 20 keys (starting from an empty tree). Then, perform the following operations in the prescribed order showing the results after each of the following operations (or implement a menu with choices. It doesn’t have to be a GUI. Displaying the menu and the results in the output window of the IDE is fine):
* search for a key which belongs in the tree;
* search for a key that does not belong to the BST;
* calculate the height;
* count the leaves;
* count the internal nodes;
* insert a new key;
* calculate the height;
* inorder traversal;
* preorder traversal;
* postorder traversal;
* count the leaves;
* count the internal nodes;
Deliverables: You should submit (1) all the source (.java) files, (2) an output sample (screenshot with program execution showing the required functionality) and (3) a document file describing your solution. The solution description document should include the following elements: a short problem analysis, main design decisions, assumptions, description of classes, user interface, testing and test cases, error handling and lessons learned. The size of the document should be of 3 pages, single spaced, font size 12. All solution description elements should be properly formatted using APA style.

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

1. Discuss why we need to balance Binary Search Trees (BSTs)
a. It stores data item in key order, we don’t need to compare item against item when the comparison asks for too much time, we compare key against key, it ‘s quicker
b. We can insert, delete, checking the existence of a item in short time   
c. When we look for an item in the tree. each comparison allows us to skip search for the half of the current tree so each checking/insertion/deletion take time proportional to the logarithm of the number of items stored in the tree
d. But the problem of BST is that it can be turned into a linked list based on the order of input item, in that case the time of checking/insertion/deletion will be linear time....

By purchasing this solution you'll be able to access the following files:

50% discount

$50.00 $25.00
for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Java Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Upload a file
Continue without uploading

We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats