Preliminaries Stage 1 due tonight by 9:00 PM HW1 discussion (4PM, Commons 9) –may try for next week? HW2 available later today, due Monday by 9:00 PM.

Slides:



Advertisements
Similar presentations
Singly linked lists Doubly linked lists
Advertisements

Stacks, Queues, and Linked Lists
Section 5 Lists again. Double linked lists – insertion, deletion. Trees.
Chapter 1 Object Oriented Programming 1. OOP revolves around the concept of an objects. Objects are created using the class definition. Programming techniques.
Hw #6 due on 3/25… Java, from the details to the bigger picture Spamventure! From the details, the big (ASCII) picture after break… emanning msheely, 1432.
Lecture Stacks. A stack is a Last-In-First-Out (LIFO) or a First-In-Last-Out (FILO) abstract data type E.g. a deck of cards in which cards may be added.
Ics202 Data Structures. hh tail head (b) LinkedList head tail Element datum next 3 Integer Element datum next 1 Integer Element datum next 4 Integer.
queues1 Queues Data structures that wait their turn.
CS Data Structures II Review COSC 2006 April 14, 2017
COMP 103 Linked Stack and Linked Queue.
Chapter 1 Object Oriented Programming. OOP revolves around the concept of an objects. Objects are crated using the class definition. Programming techniques.
Special Visitor Sean Haneberg Microsoft XBoxLive Former UB-CSE student.
Preliminaries Attendance sheets –I remembered! HW1 due tonight –progress report Stage 1 due on Friday –progress report.
A list = a Linear Recursive Structure (LRS or LRStruct) What is a list? 1.the empty list is a list 2.a pair whose tail is a list is itself a list This.
Preliminaries Attendance sheets –I remembered! Survey links –HW1 time survey –Anonymous feedback survey HW discussion (4PM, Commons 9)
Talk tonight Richard Stallman Norton 112 6:00 PM.
No homework this week Stage 2 starts next week. Code review Team with N members is assigned N submissions to review Discuss submissions within team Everyone.
How do visitors work? This set of slides traces through the execution of a visitor we’ve seen before (the lengthVisitor) on a short list. It shows how.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Sixth Edition Chapter 17: Linked Lists.
Reviews for Exam 1 Chapter 1-4 CS 211 Data Structures MHC, 2007.
Lists We’ve seen an array-based list implementation, the ArrayList. Advantage of an array-based implementation: –fast access to a specific index –typically.
Queue using an array. .head.tail Pointers head and tail always point to the first empty slot before or after elements in the list. Thus, initially they.
C++ Programming: Program Design Including Data Structures, Third Edition Chapter 17: Linked Lists.
Lists We’ve seen an array-based list implementation, the ArrayList.
Lists: array implementation list_size = 5 lst Obj 1Obj 2Obj 3Obj 4Obj 5.
Starting Out with C++: Early Objects 5/e © 2006 Pearson Education. All Rights Reserved Starting Out with C++: Early Objects 5 th Edition Chapter 17 Linked.
Week 3 - Wednesday.  What did we talk about last time?  Started linked lists.
Data Structures - Queues
CSE 131 Computer Science 1 Module 9: Linked Lists Using references to link objects Basic operations on linked lists Implementing a linked list of integers.
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.
COMP 103 Linked Lists. 2 RECAP-TODAY RECAP  Linked Structures: LinkedNode  Iterating and printing Linked Nodes  Inserting and removing Linked Nodes.
Chapter 1 Object Oriented Programming. OOP revolves around the concept of an objects. Objects are created using the class definition. Programming techniques.
Starting Out with C++ Early Objects Seventh Edition by Tony Gaddis, Judy Walters, and Godfrey Muganda Chapter 17: Linked Lists.
CSS446 Spring 2014 Nan Wang  Java Collection Framework ◦ Stack ◦ Queue & Priority Queue 2.
QUEUES What are Queues? Creating a Queue Enqueuing and Dequeuing Testing for an Empty Queue.
Implementing an ADT Having the JCFs is great – most of the significant data structures are already available But you still may need to implement your own.
Linked Lists part 1 CS 244 Brent M. Dingle, Ph.D. Game Design and Development Program Department of Mathematics, Statistics, and Computer Science University.
APS105 Lists. Structures Arrays allow a collection of elements –All of the same type How to collect elements of different types? –Structures; in C: struct.
Linked lists. Data structures to store a collection of items Data structures to store a collection of items are commonly used Typical operations on such.
LINKED LISTS Midwestern State University CMPS 1053 Dr. Ranette Halverson 1.
Patterns for Decoupling Data Structures and Algorithms Dung “Zung” Nguyen Pepperdine University / University of Houston Stephen Wong Oberlin College
1ADS Lecture 11 Stacks contd.. ADS Lecture 113 Singly Linked list-based Stack Top of stack is head of list (can insert elements at head in constant.
Warm Up – 8/28/12 Bring Kleenex EC opportunity due next week. Put in box up front. Make sure your name and period is on it. We buy our workbooks on Friday,
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Seventh Edition by Tony Gaddis, Judy.
2/21/20161 List Operations Advanced Programming Ananda Gunawardena.
Week 4 - Friday.  What did we talk about last time?  Continued doubly linked list implementation  Linked lists with iterators.
Week 4 - Wednesday.  What did we talk about last time?  Started linked lists.
Linked list: a list of items (nodes), in which the order of the nodes is determined by the address, called the link, stored in each node C++ Programming:
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Seventh Edition by Tony Gaddis, Judy.
Day 3: The Command and Visitor Patterns. Preliminaries The Java static type system uses simple rules to infer types for Java expressions. The inferred.
slides adapted from Marty Stepp and Hélène Martin
CSC 243 – Java Programming, Spring, 2014 Week 4, Interfaces, Derived Classes, and Abstract Classes.
Arrays, Link Lists, and Recursion Chapter 3. Sorting Arrays: Insertion Sort Insertion Sort: Insertion sort is an elementary sorting algorithm that sorts.
CSC 243 – Java Programming, Fall, 2008 Tuesday, September 30, end of week 5, Interfaces, Derived Classes, and Abstract Classes.
1 Lecture 9: Stack and Queue. What is a Stack Stack of Books 2.
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI CSCI 240 Abstract Data Types Queues Dale Roberts, Lecturer
Week 4 - Friday CS221.
Doubly Linked List Review - We are writing this code
Linked list insertion Head. Linked list insertion Head.
Sequences 9/18/ :20 PM C201: Linked List.
Prof. Neary Adapted from slides by Dr. Katherine Gibson
Pointers and Linked Lists
Linked Lists: Implementation of Queue & Deque
Queue and Priority Queue Implementations
A List Implementation That Links Data
Linear Recursive Structures(LRS)
CS210- Lecture 5 Jun 9, 2005 Agenda Queues
Queues: Implemented using Linked Lists
A List Implementation That Links Data
Queue, Deque, and Priority Queue Implementations
Presentation transcript:

Preliminaries Stage 1 due tonight by 9:00 PM HW1 discussion (4PM, Commons 9) –may try for next week? HW2 available later today, due Monday by 9:00 PM

LRStruct design

Empty vs. NonEmpty state (look Ma, no NullPointerException!) An LRS object delegates all calls to its LRS State object – which can respond to all messages. Empty and NonEmpty states respond differently. There is never a null pointer in the structure! (Think about the implications of this for a while.)

What is basic (invariant) list functionality? insert new item at front remove item from front set/get first item (head) set/get rest (tail) plus (in Java) methods inherited from Object (toString, equals, etc)

How are these methods defined? public LRStruct insertFront(E item) { return _state.insertFront(this, item); } public E removeFront() { return _state.removeFront(this); } public LRStruct setDatum(E item) { return _state.setDatum(this, item); } public E getDatum() { return _state.getDatum(this); } public LRStruct setRest(LRStruct rest) { return _state.setRest(this, rest); } public LRStruct getRest() { return _state.getRest(this); }

LRStruct delegates to State! All of these methods delegate to the state of the LRStruct. States polymorphically determine what happens.

Polymorphism In class discussion: –Objects behave according to their definitions –Variable of some type can refer to object of any subtype