Problem 1: recurrence is T(n) = 2T(n/2)+O(1) since there are two calls on ranges half as big as the size of [first..last] This has solution O(n) Part B: height: T(n) = 2T(n/2)+O(1) two trees half as big, solution is O(n) Note: this is solution even for unbalanced trees since T(n) = T(n-1)+O(1) for unbalanced. for isBalanced we have T(n) = 2T(n/2) + O(n) since height is O(n) this has solution O(n log n) Note that for unbalanced trees we'd get T(n) = T(n-1)+O(n) which is O(n^2) ----- Problem 2 LEFT and RIGHT serve as maps of brace/parens to an integer, providing the same integer value for corresponding braces, e.g., ( maps to 2 and ) maps to 2 using a stack ensures checking balance since it's LIFO so () matches since ( is on top of stack when ) is seen. Similarly if we assume [ ..... ] works with .... checked, then [ matches ] by the LIFO structure Part B --- return st.size() == 0 Part C: if (st.size() == 0) return false Part D add < and > to the same location in LEFT/RIGHT respectively, e.g., LEFT = LEFT + "<"; RIGHT = RIGHT + ">"; Problem 3: Part A: list.next.prev = list; Part B: while (list != null) { list.next = new DNode(str,list,list.next); // add new node if (list.next.next != null) list.next.next.prev = list.next; list = list.next.next; } Problem 4: add justin as left-child of kate, add lilly as right-child of kate and add owen as left child of patrick Part B: 2674440, 14 nodes Part B' stanley, steven, sterling, patrick Part C public int countTwo(TreeNode root) { if (root == null) return 0; int count = 0; if (root.left != null && root.right != null) count = 1; return count + countTwo(root.left) + countTwo(root.right); } Part D: here's the scenario ... first ... last ... A B C the root falls into either A, B, or C public int rangeCount(TreeNdoe root, String first, String last) { if (root == null) return 0; if (first.compareTo(root.info) <= 0 && root.info.compareTo(last) <= 0) return 1 + rangeCount(root.left,first,last) + rangeCount(root.left,first,last); if (root.info.compareTo(first < 0) return rangeCount(root.right,first,last); return rangeCount(root.left,first,last); }