| ||||||||||
Welcome to DrJava. > Queue q = new Queue() > Stack s = new Stack() > import java.util.REMOVEDkedList > REMOVEDkedList l = new REMOVEDkedList() > q.push("Fred") > q.push("Barney") > q.push("Wilma") > q.push("Betty") > s.push("Scooby") > s.push("Velma") > s.push("Shaggy") > l.addFirst(q.pop()) > l.addFirst(s.pop()) > q.push(s.pop()) > s.push(q.pop()) > s.pop() "Barney" > q.pop() "Wilma" > s.push(l.getFirst()) > q.push(l.getLast())
Is that it? The only difference? Mark Gudzial |
Okay, try saying it in your own words. |
Yes |
That's true, but that's not really an advantage, is it? |
Hmm – not quite. What can you tell me about the numbers? Recall Monday's lecture... |
Did anybody TRY the example to see what happens? Mark Guzdial |
Corali and I checked this. Swap Fred and Shaggy throughout – addFirst on REMOVEDkedList pushes the input into the FIRST position. Everything else shifts down. Mark Guzdial |
On ii. – the real issue is the class that USES the ADT. It never needs to change as the underlying implementation of the ADT changes. On iii – there are no data, just random values. In uniform, every random value in the range is equally likely. In normal, the mean is the most common, and numbers close to the mean are more likely than those far away from the mean. Stack and Queue classes are on the Syllabus page. REMOVEDkedList is Java's. Mark Guzdial |
<BIG_GRIN> |