2. public double balanceFactor(){ return 1.0 * otherHeightHelper(root) / minPossibleHeight(slowSizeHelper(root)); } private int slowSizeHelper(BSTNode n) { if( n == null ) return 0; else return 1 + slowSizeHelper(n.getLeft()) + slowSizeHelper(n.getRight()); } private int otherHeightHelper(BSTNode n) { if(n == null) return -1; else return Math.max(otherHeightHelper(n.getLeft()) + 1, otherHeightHelper(n.getRight()) + 1); } public int minPossibleHeight(int currentSize){ int result = -1; while(currentSize > 0){ currentSize /= 2; result++; } return result; } Criteria: calc height: 6 points, 2 attempt, 4 correct calc size: 6 points, 2 attempt, 4 correct calc min possible height: 6 points, 2 attempt, 4 correct calculation: 1 point return 1 point 3. public void insert(E obj, int pos){ listSize++; if(head == null){ if(!obj.equals(defaultValue)){ head = new Node(obj, null, pos); } } else if(pos <= head.getPosition()){ if(!obj.equals(defaultValue)){ head = new Node(obj, head, pos); updatePositions(head.getNext()); } else{ updatePositions(head); } } else{ Node trailer = null; Node lead = head; while(lead != null && lead.getPosition() < pos){ trailer = lead; lead = lead.getNext(); } trailer.setNext(new Node(obj, lead, pos)); updatePositions(lead); } } private void updatePositions(Node n) { while( n != null){ n.setPosition(n.getPosition() + 1); n = n.getNext(); } } Criteria: update listSize: 1 point handle case when head null: 2 points handle case when position is before head: new head: 2 points no new head: 1 point general case: traverse to correct position: 5 points insert new node: 5 points update positions: 4 points 4. public boolean remove(Object obj){ int location = obj.hashCode() % con.length; int inc = 1; boolean removed = false; while( con[location] != null && !con[location].equals(obj) ){ location = (location + inc) % con.length; inc *= 2; } if( con[location] != null && con[location] != NOTHING){ con[location] = NOTHING; removed = true; size--; } return removed; } Criteria: get hash code for obj: 1 point mod by length to get to star: 1 point search for obj: continue if null or not equal to obj: 4 points change location: 3 points alter increment: 2 points If found remove: 2 points update size: 1 point return: 1 point 5. public class Queue{ private Stack stack1; private Stack stack2; public Queue(){ stack1 = new Stack(); stack2 = new Stack(); } public void enqueue(E item){ stack1.push( item ); } public E dequeue() if(stack2.isEmpty() ) shift(); return stack2.pop(); } public E front(){ if(stack2.isEmpty() ) shift(); return stack2.top(); } public boolean isEmpty(){ return stack1.isEmpty() && stack2.isEmpty(); } private void shift(){ while( !stack1.isEmpty() ) stack2.push( stack1.pop() ); } } Criteria:(methods must be correct) enqueue: 3 points isEmpty: 4 points dequeue: 5 points front: 3 points