Presentation is loading. Please wait.

Presentation is loading. Please wait.

Clicker questions and stuff 12/5/13 CSE 1102 Fall 2013.

Similar presentations


Presentation on theme: "Clicker questions and stuff 12/5/13 CSE 1102 Fall 2013."— Presentation transcript:

1 Clicker questions and stuff 12/5/13 CSE 1102 Fall 2013

2 The country with the red star on it is: 1. Estonia 2. Belarus 3. Latvia [correct ] 4. Lithuania 5. None of the above

3 Topic 1: Implementing Queues

4 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

5 ADT: defined by capabilities (interface in Java) public interface QueueADT { void enqueue(ElementType t); ElementType dequeue(); ElementType front(); boolean isEmpty(); }

6 So let's use an instance variable for the _front, as we did with top of Stack Queue wilma = new Queue (); // create empty Queue // now add some stuff wilma.enqueue(new Car(Color.blue)); wilma.enqueue(new Car(Color.red));

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

8 A. enqueue() [correct ] 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?

9 So let's use two instance variables, _front and _rear, in our Queue implementation Queue wilma = new Queue (); // create empty Queue // now add some stuff wilma.enqueue(new Car(Color.blue)); wilma.enqueue(new Car(Color.red));

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

11 A. enqueue() B. dequeue() C. front() D. isEmpty() E. All of these take roughly the same amount of time [correct ] 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?

12 A. _front in wilma (that is, wilma._front ) [correct ] 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)?

13 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 [correct ] 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)?

14 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?

15 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

16 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

17 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, …

18 Chapter 9: Design Patterns Holder pattern Proxy pattern Composite pattern (plus Model-View-Controller – not in chapter 9 though)

19 Chapter 11: Loops for loops while loops do-while loops loop-de loops (?) (mostly used for traversing structures, especially…)

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

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

22 The final exam cumulative, but more emphasis on 2 nd 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


Download ppt "Clicker questions and stuff 12/5/13 CSE 1102 Fall 2013."

Similar presentations


Ads by Google