clicker questions and stuff 12/5/13 cse 1102 fall 2013
Post on 05-Jan-2016
215 Views
Preview:
TRANSCRIPT
Clicker questions and stuff12/5/13
CSE 1102 Fall 2013
The country with the red star on it is:
1. Estonia
2. Belarus
3. Latvia
4. Lithuania
5. None of the above
Topic 1: Implementing Queues
Example ADT: Queue
Operations:• enqueue(element) – adds element to
"back" of the queue• dequeue – returns the "front" element of
the queue, which is removed from the queue
• front – returns the front element of the queue without changing the queue
• isEmpty – returns true if queue is empty, false otherwise
ADT: defined by capabilities(interface in Java)
public interface QueueADT<ElementType>{
void enqueue(ElementType t);
ElementType dequeue();
ElementType front();
boolean isEmpty();
}
So let's use an instance variable for the _front, as we did with top of Stack
Queue<Car> wilma = new Queue<Car>();
// create empty Queue
// now add some stuff
wilma.enqueue(new Car(Color.blue));
wilma.enqueue(new Car(Color.red));
So let's use an instance variable for the _front, as we did with top of Stack ctd.
// now remove something
Car bill = wilma.dequeue();
Car joe = wilma.dequeue();
A. enqueue()
B. dequeue()
C. front()
D. isEmpty()
E. All of these take roughly the same amount of time
Using this Node implementation of a Queue, which of these operations can take substantially more (i.e. perhaps 10 times more) time than the others?
So let's use two instance variables, _front and _rear, in our Queue implementation
Queue<Car> wilma = new Queue<Car>();
// create empty Queue
// now add some stuff
wilma.enqueue(new Car(Color.blue));
wilma.enqueue(new Car(Color.red));
So let's use two instance variables, _front and _rear, in our Queue implementation ctd.
// now remove some stuff
Car bill = wilma.dequeue();
Car joe = wilma.enqueue();
A. enqueue()
B. dequeue()
C. front()
D. isEmpty()
E. All of these take roughly the same amount of time
Using this Node implementation of a Queue, which of these operations can take substantially more (i.e. perhaps 10 times more) time than the others?
A. _front in wilma (that is, wilma._front)
B. _rear in wilma (that is, wilma._rear)
C. wilma._front, then wilma._front._next
D. wilma._rear._next, then wilma._rear
E. All of the above, in some order
This instance (or Object) diagram represents a Queue. If I dequeue something, what changes (in the Queue)?
A. _front in wilma (that is, wilma._front)
B. _rear in wilma (that is, wilma._rear)
C. wilma._front, then wilma._front._next
D. wilma._rear._next, then wilma._rear
E. All of the above, in some order
This instance (or Object) diagram represents a Queue. If I enqueue something, what changes (in the Queue)?
Topic 3: The importance of interfaces
In Chapter 14 we saw
• StackADT and Stack
•QueueADT and Queue
What does that mean in terms of clients?
What do we get from encapsulation?
Are there alternative ways to implement StackADT and QueueADT?
Topic 4: Wrapping up
We have covered material from chapters 1, 2, 3, 4, 5, 7, 8, 9, 11, 13*, and 14*
7, 8, 9, 11, 13*, and 14* since the midterm
Chapter 7: 2D graphic shapes
• Graphics2D and Swing shapes
• Graphics and Graphics2D objects
• "Smart" shapes – adding information to existing 2D shapes
• Java event model: – Sources– Listeners– Responders
Chapter 8: GUI widgets and events
• GUIs using windows, pushbuttons, and radio buttons
• Layout classes: flow, border, and grid
• Button groups
• MouseEvents, MouseListeners, and MouseAdapters
• ActionListeners, ItemListeners, ChangeListeners, …
Chapter 9: Design Patterns
• Holder pattern
• Proxy pattern
• Composite pattern
• (plus Model-View-Controller – not in chapter 9 though)
Chapter 11: Loops
• for loops
• while loops
• do-while loops
• loop-de loops (?)
• (mostly used for traversing structures, especially…)
Chapter 13: arrays
• 1d and 2d arrays
• Three steps:– Declare array– Instantiate array– Instantiate array elements
• length
• dynamically changing size of arrays
• traversing arrays with loops
• (didn't do ArrayList or Vector classes)
Chapter 14: Intro data structures
• Abstract data types
• Separation between abstract behavior and implementation
• Stack
• Queue
• Intro to generics
• Use of Node class
• (didn't do List, Dictionary)
The final exam
• cumulative, but more emphasis on 2nd half
• There will be questions where you:– Answer questions about code– Answer questions about concepts (e.g. define
and/or contrast)– Write some code to do some tasks
Tuesday, December 10, 10:30-12:30
• Closed book, closed notes, no electronics
top related