| ||||||||||

Consider the series of commands typed into the Interactions Pane of DrJava:

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())

What is in each of Stack s, Queue q, and REMOVEDkedList l after the above code is executed? Be sure to label the head and tail on the stack and queue.

i. What's the difference between a discrete and continuous simulation?

ii. What's an Abstract Data Type? Identify a data structure that we've defined as an ADT. What's the advantage of defining an ADT?

iii. What's the difference between a normal and uniform distribution?

hey uh, I wasn't in class that day so, "What's the difference between a discrete and continuous simulation?"

Q: (Head) Wilma -> Betty -> Velma -> Fred (Tail)

S: (Head) Shaggy -> Barney -> Scooby (Tail)

L: Shaggy -> Fred

Did I get it? Did I Did I? :-)

Student43

B.

i. In a discrete event simulation, simulation time is not equal to real time.

Is that it? The only difference? Mark Gudzial |

ii. Found this in the notes "An abstract type is a description of the methods that a data structure knows and what the methods do", but I really don't understand it.

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... |

Q: (Head) Betty -> Velma -> Fred (Tail)

S: (Head) Shaggy -> Scooby (Tail)

L: empty

Did anybody TRY the example to see what happens? Mark Guzdial |

Q:(head)Wilma->Betty->Velma->Shaggy(tail)

S:(head)Fred->Barney->Scooby(tail)

LL:Fred->Shaggy

Haven't tried it on Dr.Java yet, but pretty sure it's right Student32

I cant find the queue java-source!

sorry guys...the third time i tried it i got:

Q:(head)betty->Velma->Shaggy(tail)

S:(head)Fred->Scooby

LL:Fred->Shaggy

Student32

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 |

i. continuous-each moment of time is simulated(every moment counts)

discrete-skip to the important moments(simulate 100 years)

ii. adt-description of methods and what they do that a data structure knows. ex-queue minus the implementation

advantage-you are able to reuse code. for exmaple, if you created an abstarct class that is called animals and it included number of feet, type of food, etc. Then we created a kangaroo class that extended animal, we could just say number of feet = 2, type of food = grass.

iii. uniform-every peice of data is approx. equal. normal-data comes to a peak and then slopes back down, bell shaped or like a mountain.

how can we run this code without the class? where's the class?

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 |

1:

q = Betty Scooby Fred

s = Shaggy Scooby

l = Shaggy Fred

B: 1-Continuous is every timeframe is simulated. Discrete is when you just skip to the events.

I really don't understand all the code. Can we discuss this in class before the quiz? I've been to all the lectures and the pushing/popping/adding is confusing.

Q: fred velma betty

S: shaggy scooby

L: shaggy –> fred

what's the advantage of defining an ADT??

Q: Betty, Velma, Fred

S: Scooby, Shaggy

L: Shaggy, Fred

Student50

I sat down at the quiz. And suddenly everything made sense. Whew!

<BIG_GRIN> |

- Announcements-Spring 2005 last edited on 29 April 2005 at 8:41 am by guzdial-pb.cc.gatech.edu
- PreQuizzes-Spring 2005 last edited on 18 April 2005 at 10:28 pm by user-1121r4v.dsl.mindspring.com