Here is a quick sketch of the solutions. In grading, I am looking only for a few things on each question, and an overall understanding of the important concepts. 1. (a) O( N^2 ) because the calls to add are O(N) each (b) O( N^2 ) because the calls to get are O(N) each (c) O( N ) because the calls to add and get are both O(1) each (d) For a quadratic algorithm, when N is increased by a factor of 3, the running time increases by a factor of 9. So the time will be 90 sec. (e) Use a ListIterator to traverse the list backwards and use the one-parameter add which is efficient on all lists. 2. (a) size is O(N) the other two are O(1). (b) public int size( ) { int count = 0; for( Node p = header.next; p != tail; p = p.next ) count++; return count; } (c) public void remove( Node p ) { p.next.prev = p.prev; p.prev.next = p.next; } (d) public void addBefore( Node p, AnyType x ) { p.prev = p.prev.next = new Node( x, p.prev, p ); } 3. (a) public static List getMostNumbers( Map> m ) { List result = new ArrayList( ); int maxNumbers = 0; for( Map.Entry> e : m.entrySet( ) ) { if( e.getValue( ).size( ) > maxNumbers ) { result.clear( ); maxNumbers = e.getValue( ).size( ); } if( e.getValue( ).size( ) == maxNumbers ) // not an else result.add( e.getKey( ) ); } return result; } (b) This is an O( N ) algorithm 4. public static int countDirectories( File d ) { if( !d.isDirectory( ) ) return 0; int count = 1; for( File f : d.listFiles( ) ) count += countDirectories( f ); return count; }