clicker questions and stuff 12/5/13 cse 1102 fall 2013

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

Upload: rhoda-armstrong

Post on 05-Jan-2016

215 views

Category:

Documents


2 download

TRANSCRIPT

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

Clicker questions and stuff12/5/13

CSE 1102 Fall 2013

Page 2: Clicker questions and stuff 12/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

Page 3: Clicker questions and stuff 12/5/13 CSE 1102 Fall 2013

Topic 1: Implementing Queues

Page 4: Clicker questions and stuff 12/5/13 CSE 1102 Fall 2013

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

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

ADT: defined by capabilities(interface in Java)

public interface QueueADT<ElementType>{

void enqueue(ElementType t);

ElementType dequeue();

ElementType front();

boolean isEmpty();

}

Page 6: Clicker questions and stuff 12/5/13 CSE 1102 Fall 2013

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

Page 7: Clicker questions and stuff 12/5/13 CSE 1102 Fall 2013

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

Page 8: Clicker questions and stuff 12/5/13 CSE 1102 Fall 2013

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?

Page 9: Clicker questions and stuff 12/5/13 CSE 1102 Fall 2013

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

Page 10: Clicker questions and stuff 12/5/13 CSE 1102 Fall 2013

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

Page 11: Clicker questions and stuff 12/5/13 CSE 1102 Fall 2013

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?

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

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

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

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

Page 14: Clicker questions and stuff 12/5/13 CSE 1102 Fall 2013

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?

Page 15: Clicker questions and stuff 12/5/13 CSE 1102 Fall 2013

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

Page 16: Clicker questions and stuff 12/5/13 CSE 1102 Fall 2013

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

Page 17: Clicker questions and stuff 12/5/13 CSE 1102 Fall 2013

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

Page 18: Clicker questions and stuff 12/5/13 CSE 1102 Fall 2013

Chapter 9: Design Patterns

• Holder pattern

• Proxy pattern

• Composite pattern

• (plus Model-View-Controller – not in chapter 9 though)

Page 19: Clicker questions and stuff 12/5/13 CSE 1102 Fall 2013

Chapter 11: Loops

• for loops

• while loops

• do-while loops

• loop-de loops (?)

• (mostly used for traversing structures, especially…)

Page 20: Clicker questions and stuff 12/5/13 CSE 1102 Fall 2013

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)

Page 21: Clicker questions and stuff 12/5/13 CSE 1102 Fall 2013

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)

Page 22: Clicker questions and stuff 12/5/13 CSE 1102 Fall 2013

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