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

Slides:



Advertisements
Similar presentations
STACKS & QUEUES. Stacks Abstract data types An abstract data type (ADT) is an abstraction of a data structure An ADT specifies : –Data stored –Operations.
Advertisements

So what's next? Introduction to data structures Two Perspectives: Abstract description (capabilities) Implementation(s) For structures: Stack Queue Deque.
Data Structures A data structure is a collection of data organized in some fashion that permits access to individual elements stored in the structure This.
Queues1 Part-B2 Queues. Queues2 The Queue ADT (§4.3) The Queue ADT stores arbitrary objects Insertions and deletions follow the first-in first-out scheme.
0 of 37 Stacks and Queues Lecture of 37 Abstract Data Types To use a method, need to know its essentials: signature and return type o additionally,
CHAPTER 7 Queues.
ADT Stacks and Queues. Stack: Logical Level “An ordered group of homogeneous items or elements in which items are added and removed from only one end.”
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 18: Stacks And Queues.
Copyright © 2012 Pearson Education, Inc. Chapter 18: Stacks And Queues.
Chapter 5 Queues Modified. Chapter Scope Queue processing Comparing queue implementations 5 - 2Java Software Structures, 4th Edition, Lewis/Chase.
CS Data Structures II Review COSC 2006 April 14, 2017
CSE 143 Lecture 22: Advanced List Implementation (ADTs; interfaces; abstract classes; inner classes; generics; iterators)
Java Programming, 3e Concepts and Techniques Chapter 5 Arrays, Loops, and Layout Managers Using External Classes.
Chapter 12: Data Structures
OrderedListADT. Overview OrderedListADT: not the same as linked lists The OrderedListADT: operations and sample applications An ArrayList implementation.
Unit 11 1 Unit 11: Data Structures H We explore some simple techniques for organizing and managing information H This unit focuses on: Abstract Data Types.
CS 206 Introduction to Computer Science II 10 / 20 / 2008 Instructor: Michael Eckmann.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Java Software Solutions Foundations of Program Design Sixth Edition by Lewis.
Queues CS-240 & CS-341 Dick Steflik. Queues First In, First Out operation - FIFO As items are added they are chronologically ordered, items are removed.
CS 206 Introduction to Computer Science II 10 / 26 / 2009 Instructor: Michael Eckmann.
1 Data Structures  We can now explore some advanced techniques for organizing and managing information  Chapter 12 of the book focuses on: dynamic structures.
Queues CS-240 & CS-341 Dick Steflik. Queues First In, First Out operation - FIFO As items are added they are chronologically ordered, items are removed.
Chapter 12 Collections. © 2004 Pearson Addison-Wesley. All rights reserved12-2 Collections A collection is an object that helps us organize and manage.
COMPSCI 125 Spring 2005 ©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. Odds and Ends Strings (from Chapter 9) StringTokenizer.
1 Foundations of Software Design Fall 2002 Marti Hearst Lecture 13: Queues and Vectors.
Queues. From last time: Java's built-in java.util.Stack class Consider the javadoc for Java’s built-in java.util.Stack class (
Queues CS-240 & CS-341 Dick Steflik. Queues First In, First Out operation – FIFO As items are added they are chronologically ordered, items are removed.
1 Stack Data : a collection of homogeneous elements arranged in a sequence. Only the first element may be accessed Main Operations: Push : insert an element.
© 2004 Pearson Addison-Wesley. All rights reserved12-1 Chapter 12 : Collections Intermediate Java Programming Summer 2007.
Chapter 4 Linked Structures – Stacks Modified. Chapter Scope Object references as links Linked vs. array-based structures Managing linked lists Linked.
CSE 373 Data Structures and Algorithms Lecture 2: Queues.
Data Structures - Queues
Stack and Queue.
© 2006 Pearson Education Chapter 12: Data Structures Presentation slides for Java Software Solutions for AP* Computer Science A 2nd Edition by John Lewis,
Chapter 3 List Stacks and Queues. Data Structures Data structure is a representation of data and the operations allowed on that data. Data structure is.
Data Structures and Abstract Data Types "Get your data structures correct first, and the rest of the program will write itself." - David Jones.
Clicker questions 11/21/13 CSE 1102 Fall neighbors, (i,j) = (2,2) [0][0] [i][j]
Copyright © 2012 Pearson Education, Inc. Chapter 18: Stacks And Queues.
CSE 12 – Basic Data Structures Cynthia Bailey Lee Some slides and figures adapted from Paul Kube’s CSE 12 CS2 in Java Peer Instruction Materials by Cynthia.
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 18 Stacks and Queues.
1 Stacks and Queues Starring: IndexOutOfBOundsException Co-Starring: NoSuchElementException.
ELC 310 Day 24. © 2004 Pearson Addison-Wesley. All rights reserved12-2 Agenda Questions? Problem set 5 Parts A & B Corrected  Good results  2 A’s, 1.
Lab 7 Queue ADT. OVERVIEW The queue is one example of a constrained linear data structure. The elements in a queue are ordered from least recently added.
CSE 143 Lecture 24 Advanced collection classes (ADTs; abstract classes; inner classes; generics; iterators) read 11.1, 9.6, , slides.
Chapter 12: Collections by Lewis and Loftus (Updated by Dan Fleck) Coming up: Collections.
Stacks And Queues Chapter 18.
1 Linked-list, stack and queue. 2 Outline Abstract Data Type (ADT)‏ Linked list Stack Queue.
QUEUES What are Queues? Creating a Queue Enqueuing and Dequeuing Testing for an Empty Queue.
1 Stacks (Continued) and Queues Array Stack Implementation Linked Stack Implementation The java.util.Stack class Queue Abstract Data Type (ADT) Queue ADT.
Week 2 - Friday.  What did we talk about last time?  Computing Big Oh.
CSE 373: Data Structures and Algorithms Lecture 2: Queues.
Chapter 5 Array-Based Structures © 2006 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.
3/3/20161 Stacks and Queues Introduction to Data Structures Ananda Gunawardena.
Winter 2006CISC121 - Prof. McLeod1 Stuff Solution to midterm is posted. Marking has just started… Lab for this week is not posted (yet?). Final exam (full.
Chapter 4 ADTs Stack and Queue. 4-2 Formal ADT Specifications The Java interface construct lets us collect together method interfaces into a syntactic.
M180: Data Structures & Algorithms in Java Stacks Arab Open University 1.
1 Queues (Continued) Queue ADT Linked queue implementation Array queue implementation Circular array queue implementation Deque Reading L&C , 9.3.
Clicker quiz 11/5/13 CSE 1102 Fall A. a FlowLayout B. a BorderLayout C. a GridGrouping D. a JSplitPane E. a GridLayout Suppose we want to to lay.
Sections 3.4 Formal Specification
12 Collections Software Solutions Lewis & Loftus java 5TH EDITION
Chapter 12: Data Structures
Stacks and Queues.
Week 15 – Monday CS221.
CMSC 341 Lecture 5 Stacks, Queues
CSC 143 Queues [Chapter 7].
18.5 Linked Queues Like a stack, a queue can be implemented using pointers and nodes Allows dynamic sizing, avoids issue of wrapping indices NULL front.
Queues 12/30/2018 9:24 PM Queues 12/30/2018 9:24 PM Queues.
Queues CSC212.
slides created by Alyssa Harding
Data Structures & Programming
Presentation transcript:

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 [correct ] 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 { 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 wilma = new Queue (); // 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() [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?

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

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

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

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

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