Homework 9 - /*Page 601 #1 - 9, 13 Clarifications: For #2:...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
/*Page 601 #1 - 9, 13 Clarifications: For #2: assume that items are added to front of deque. For #5, assume that priority is interpreted as coming first in a lexicographical ordering (dictionary order) For #8 and #9, assume that a customer is considered "served" if they are finished waiting by the end of the simulation, even if there wasn't enough time to finish their transaction. */ //P601 #1. If you add the objects x,y, and z to an initially empty queue, in what order will three //dequeue operations remove them from the queue? (enqueue) x x y x y z (dequeue) y z z empty //#2.If you add the objects x,y, and z to an initially empty deque, in what order will three //removeBack operations remove them from the deque? (addToFront) x y x z y x (removeBack) z y z empty /*#3. QueueInterface<String> myQueue = new LinkedQueue<String>(); myQueue.enqueue("Jane"); myQueue.enqueue("Jess"); myQueue.enqueue("Jill"); myQueue.enqueue(myQueue.dequeue()); myQueue.enqueue(myQueue.getFront()); myQueue.enqueue("Jim"); String name = myQueue.dequeue(); myQueue.enqueue(myQueue.getFront()); */ Jane Jane Jess
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Jane Jess Jill Jess Jill Jane Jess Jill Jane Jess Jess Jill Jane Jess Jim Jill Jane Jess Jim Jill Jane Jess Jim Jill /*#4. DequeInterface<String> myDeque = new LinkedDeque<String>(); myDeque.addToFront("Jim"); myDeque.addToFront("Jess"); myDeque.addToBack("Jill"); myDeque.addToBack("Jane"); String name = myDeque.removeFront(); myDeque.addToBack(name); myDeque.addToBack(myDeque.getFront()); myDeque.addToFront(myDeque.removeBack()); myDeque.addToFront(myDeque.getBack()); */ Jim Jess Jim Jess Jim Jill Jess Jim Jill Jane Jim Jill Jane (name=Jess) Jim Jill Jane Jess Jim Jill Jane Jess Jim Jim Jim Jill Jane Jess Jess Jim Jim Jill Jane Jess /*5 PriorityQueueInterface<String> myPriorityQueue = new LinkedPriorityQueue<String>();
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/23/2012 for the course CS 111C taught by Professor Metzler during the Spring '11 term at City College of San Francisco.

Page1 / 6

Homework 9 - /*Page 601 #1 - 9, 13 Clarifications: For #2:...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online