Cash-back offer from April 23rd to 27th, 2024: Get a flat 10% cash-back credited to your account for a minimum transaction of $50.Post Your Questions Today!

Question DetailsNormal
$ 18.00

UMUC CMSC 350 Project 2 Balancing Binary Search Trees | Complete Solution

Question posted by
Online Tutor Profile
request

UMUC CMSC 350 Project 2 Balancing Binary Search Trees


1. Specification The search effort for locating a node in a Binary Search Tree (BST) depends on the tree shape (topology). For a BST with n nodes the ACE value is defined (Wiener and Pinson) as the Average Comparison Effort for locating a node in a tree by summing all comparison operations for all tree nodes and dividing the result by the total number of tree nodes:
for (int level = 0, sum = 0; level < treeHeight; level++ ) { sum += numberOfNodesAtLevel(level) * (level + 1) } ACE = sum / n
When the average comparison effort (i.e. the ACE value) gets over a certain threshold or after a certain number of tree insert/delete operations, for optimizing the search process, a tree balance operation should be executed resulting a tree whose height equals |_ log n _| + 1 (or floor(log n) + 1), thus requiring at most |_ log n _| + 1 (or floor(log n) + 1) comparison operations to identify any tree node. For a given BST with n nodes we define MinACE as the minimum value of ACE and MaxACE as the maximum value of ACE. MinACE value for a BST with n nodes, corresponds to the ACE value calculated for a BST of height floor(log n) + 1 which has all levels completely full, except for the last level. ACE value of a balanced BST equals MinACE. MaxACE value for a BST with n nodes corresponds to the ACE value calculated for a BST which degenerates into a linear linked list with n nodes.
Part 1 Consider the attached file BST.java which defines a generic Binary Search Tree class. Enhance the BST class with the following methods:
 treeHeight, calculates tree height;
 nodeBalanceLevel calculates the balance level of a user specified node as the difference between the height of its left subtree and the height of its right subtree;
 numberOfNodesAtLevel calculates the number of nodes at the specified level;
 calculateACE, calculates the ACE value according to the above algorithm;
 calculateMinACE, calculates the minimum value of the ACE;
 calculateMaxACE, calculates the maximum value of the ACE;
 needsBalancing, evaluates whether this BST needs to be balanced or not. We consider that a BST needs to be balanced when its ACE value is greater than K * MinACE where K = 1.2;
 balanceBST, executes the balance operation on this BST;
Additional methods may be added if necessary. The enhanced BST class should compile without errors.
Part 2 Design and implement a driver program TestBST for testing the methods implemented in Part 1. The driver program should build an initial BST whose nodes contain positive integer values taken from an input file. In the input file, the values should be separated by the semicolon character. After building the BST, in a loop, the program should invite the user to select for execution one of the following operations: (1) in-order tree traversal, (2) pre-order tree traversal, (3) calculateACE, (4) calculateMinACE, (5) calculateMaxACE, (6) numberOfNodesAllLevels (this operation displays the number of nodes at each level of the tree), (7) treeHeight, (8) nodeBalanceLevel (9) needsBalancing, (10) balanceBST, (11) insert value, and (0) exit the loop and the program. As a result of each operation execution, relevant information will be displayed to the user. For example, as a result of executing the in-order traversal, the values of the tree nodes should be shown to the console or, as a result of executing the calculateACE operation, the ACE value should be displayed to the console.
Notes. 1. If an operation requires additional information, the user will be prompted to enter it. 2. The input file (a simple .txt file) should be generated by the students using a simple text editor such as Notepad. 3. You may assume that there are no errors in the input file structure. 4. Tree root is considered as located at level 0. Tree height will be considered by counting the nodes, starting with the root, along the longest path.
2. Submission requirements Submit the following before the due date listed in the Calendar:
1. All .java source files and the input file. The source code should use Java code conventions and appropriate code layout (white space management and indents) and comments.
2. The solution description document <YourSecondName>_P2 (.pdf or .doc / .docx) containing: (2.1) assumptions, main design decisions, error handling; (2.2) test cases and two relevant screenshots; (2.3) lessons learned and (2.4) possible improvements. The size of the document file (including the screenshots) should be of 3 pages, single spaced, font size 12.

Available Answer
$ 18.00

[Solved] UMUC CMSC 350 Project 2 Balancing Binary Search Trees | Complete Solution

  • This Solution has been Purchased 2 time
  • Submitted On 07 Feb, 2016 05:46:59
Answer posted by
Online Tutor Profile
solution
protected TreeNode root; protected int size = 0; /** Create...
Buy now to view the complete solution
Other Similar Questions
User Profile
vpqnr...

UMUC CMSC 350 Project 3 complete solutions correct answers key

UMUC CMSC 350 Project 3 complete solutions correct answers key Quick Sort Optimizations through Hybridization 1. Specification Part 1 Consider the attached QuickSort algorithm for sorting arrays and two algorithm optimizat...
User Profile
vpqnr...

UMUC CMSC 350 Project 1 complete solutions correct answers key

UMUC CMSC 350 Project 1 complete solutions correct answers key 1. Specification Part 1 Design, implement and test a generic stack class StackUMUC (this name is chosen as to avoid confusion with similar classes defined in...
User Profile
Homew...

UMUC CMSC 350 Project 2 Balancing Binary Search Trees | Complete Solution

Protected TreeNode root; protected int size = 0; /** Create a default binary tree */ public BST() { } /** Create a binary tree from an array of objects */ public BST(E[] objects) { for (int i = 0; i < objects.len...
User Profile
Exper...

UMUC CMSC 350 Homework 1 | Complete Solution

A1) Running time complexity of calculateBruteForce() is O(n^2) whereas running time complexity of calculateHorner() is O(n). a2) calculateHorner() method will take less time because it takes O(n) time to perform the same ta...

The benefits of buying study notes from CourseMerits

homeworkhelptime
Assurance Of Timely Delivery
We value your patience, and to ensure you always receive your homework help within the promised time, our dedicated team of tutors begins their work as soon as the request arrives.
tutoring
Best Price In The Market
All the services that are available on our page cost only a nominal amount of money. In fact, the prices are lower than the industry standards. You can always expect value for money from us.
tutorsupport
Uninterrupted 24/7 Support
Our customer support wing remains online 24x7 to provide you seamless assistance. Also, when you post a query or a request here, you can expect an immediate response from our side.
closebutton

$ 629.35