ComputerScienceExpert

(11)

$18/per page/

About ComputerScienceExpert

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Applied Sciences,Calculus See all
Applied Sciences,Calculus,Chemistry,Computer Science,Environmental science,Information Systems,Science Hide all
Teaching Since: Apr 2017
Last Sign in: 103 Weeks Ago, 2 Days Ago
Questions Answered: 4870
Tutorials Posted: 4863

Education

  • MBA IT, Mater in Science and Technology
    Devry
    Jul-1996 - Jul-2000

Experience

  • Professor
    Devry University
    Mar-2010 - Oct-2016

Category > Programming Posted 05 May 2017 My Price 8.00

Tree program and it's height

Hi! I have this Binary Search Tree program and it's height is currently 28, I want to get it down to 16. What can I do to my program to make this degenerate BST, a balanced one?

 

class Hash{private final static String[] reserved ={ "abstract","assert","boolean","break","byte","case","catch","char","class","const","continue","default","do","double","else","extends","final","finally","float","for","goto","if","implements","import","instanceof","int","interface","long","native","new","package","private","protected","public","return","short","static","super","switch","synchronized","this","throw","throws","transient","try","void","volatile","while" };public static void main(String [] args){HashedBST<String, Integer> hbst = new HashedBST<String, Integer>();for (int index = 0; index < reserved.length; index += 1){hbst.put(reserved[index], index);}System.out.println(hbst.height());for (int index = 0; index < reserved.length; index += 1){System.out.format("%02d %s", hbst.get(reserved[index]), reserved[index]);System.out.println();}}}class HashedBST<Key extends Comparable<Key>, Value>{private class TreeNode{private TreeNode left;private TreeNode right;private Key key;private Value value;private TreeNode(Key key, Value value){this.left = null;this.right = null;this.key = key;this.value = value;}}private class ValueNode{private Key key;private Value value;private ValueNode next;private ValueNode(Key key, Value value, ValueNode next){this.key = key;this.value = value;this.next = next;

Answers

(11)
Status NEW Posted 05 May 2017 08:05 AM My Price 8.00

-----------

Not Rated(0)