Assignment 1
Due Monday, June 20 at 9:00 AM
Be sure you are acquainted with my collaboration policy and my late policy, both found on the main course webpage. For now, to turn in your assignment, email it to both me and Srividya.
-
Write a new method, equals, as part of the
SimpleArrayList class.
Here is the method header:
public boolean equals ( Object ob )
The equals method should return true
iff parameter ob is a List and
the SimpleArrayList and ob
contain the same elements in the same order.
Two elements e1 and e2 are the same iff
they are both null or e1.equals(e2).
(You can use Java's instanceof operator to test
whether ob is a List.)
-
Write an equivalent method as part of the SimpleLinkedList class.
Using Big-O notation, give the worst-case time complexity for
each of your equals methods.
If you use one or more variables (e.g., N, M),
be sure to say what those variables measure.
Write a brief justification for the time complexities you give.
Include in your justification assumptions you make about the
complexity of any methods that are called by your method.
Solution
Assignment 1 Solutions