CS2852
		
		
		
Homework
		
Week 1
Complete by 8am Friday of week 1 - be prepared to ask questions in class
- Implement the ArrayList.remove(int index)method.
- Implement the ArrayList.remove(Object target)method.
Week 2
Complete by 8am Monday of week 2 - be prepared to ask questions in class
- Watch Introduction to ArrayLists video and prepare questions and feedback for your instructor
- Watch Introduction to LinkedLists video and prepare questions and feedback for your instructor
- Study Collection and List interfaces and prepare questions and feedback for your instructor
- Study Array-Based Lists, ArrayList review and prepare questions and feedback for your instructor
- Study Generics in Java and prepare questions and feedback for your instructor
Complete by 8am Friday of week 2 - be prepared to ask questions in class
- Give the Big-O time complexity for the following algorithm.  Justify your answer.
public static boolean areUnique(List<String> strings) { boolean areUnique = true; for(int i=0; areUnique && i<strings.size(); ++i) { for(int j=0; areUnique && j<strings.size(); ++j) { if(i!=j && strings.get(i).equals(strings.get(j)) { areUnique = false; } } } return areUnique; }
- Give the Big-O time complexity for the following algorithm.  Justify your answer.
public static boolean areUnique(List<String> strings) { boolean areUnique = true; for(int i=0; areUnique && i<strings.size(); ++i) { for(int j=i+1; areUnique && j<strings.size(); ++j) { if(strings.get(i).equals(strings.get(j)) { areUnique = false; } } } return areUnique; }
- Give the Big-O time complexity for T(n) = 8 + 17n + 3n2.
Week 3
Complete by lecture 1 of week 3 - be prepared to ask questions in class
- Study Iterators and prepare questions and feedback for your instructor
- Study Linked Lists and prepare questions and feedback for your instructor
- Implement the ArrayList::ArrayListIterator.remove()method.
- Implement the LinkedList.add(int, E)method.
Complete by lecture 2 of week 3 - be prepared to ask questions in class
- Implement the LinkedList.iterator()method and the complete inner class that implements theIteratorinterface.
Week 4
Complete by 8am Monday of week 4 - be prepared to ask questions in class
- Watch these to screencasts on Big-O time complexity: first and second and prepare questions and feedback for your instructor
Week 5
Complete by lecture 1 of week 6 - be prepared to ask questions in class
- Implement a method, parenChecker, that accepts aStringand returnstrueif the parenthesization is legal. The method must make use of theStackdeveloped in lecture.- ((a + b) + c)— Good
- ([a + b] + c)— Good
- (a + {b + c})— Good
- ((a + b) + c— Bad
- ([a + b] + c]— Bad
- (a + {b + c)}— Bad
 
- Finish implementing the CircularQueueclass we began in lecture.
- Implement boolean binarySearch(List<E> list, E target)which returns true if thelistcontainstarget. You may assume that the list is sorted. You may not use recursion.
Week 6
- Implement the size()method (along with a recursive method) for theBSTclass developed in lecture.
- Implement the contains()method (along with a recursive method) for theBSTclass developed in lecture.
- Implement the toString()method (along with a recursive method) for theBSTclass developed in lecture that returns a string containing all of the elements in sorted order.
Week 7
- Implement a recursive method, numberOfLeaves()that returns the number of leaf nodes in the tree.
- Implement a recursive method, max()that returns the largest value of the tree.
- Implement a recursive method, min()that returns the smallest value of the tree.
- Just for fun: Implement a recursive method, getIthLargest()that returns the ith largest value of the tree. [This one is a bit more challenging. You would not be expected implement this on a quiz or exam.]
Week 8
- Complete the following methods for the HashTableclass we started in lecture:contains(),remove(),clear(),size(), andisEmpty().
Week 9
- Modify the inner Nodeclass from theBSTclass to have one addtional attribute:Node<E> parent, that refers to the parent of the node.
- Implement a recursive height(Node<E> subroot) method that will return the height of the subtree (zero if passednull)
- Implement, balanceFactor(Node<E> subroot), that returns the difference between the height of the left subtree and the height of the right subtree.
- Implement rightRotate(Node<E> subroot), which performs a right rotation aroundsubrootand returns a reference to the node that takes the place ofsubrootin the tree.
- Assume leftRotate()has also been implemented. Modify theadd()implementation such that the BST does not violate the rules associated with an AVL tree
- Give an example of when a deep copy is required. Explain what would go wrong if a shallow copy is performed instead.
Last modified: Tuesday, 10-Jan-2017 00:48:18 EST