CSSE221: Software Dev. Honors Day 13 Announcements Announcements Contractions throughout the night… Contractions throughout the night… Late day assignments.

Slides:



Advertisements
Similar presentations
Chapter 24 Lists, Stacks, and Queues
Advertisements

Lists and the Collection Interface Chapter 4. Chapter Objectives To become familiar with the List interface To understand how to write an array-based.
The List ADT Textbook Sections
1 Array-based Implementation An array Q of maximum size N Need to keep track the front and rear of the queue: f: index of the front object r: index immediately.
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,
Queues 4/14/2017 5:24 PM 5.2 Queues Queues Dr Zeinab Eid.
CHAPTER 4 Queues MIDTERM THURSDAY, OCTOBER 17 IN LAB.
Chapter 6 Linked Structures © 2006 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.
Queues Chapter 6. Chapter Objectives  To learn how to represent a waiting line (queue) and how to use the methods in the Queue interface for insertion.
CSSE221: Software Dev. Honors Day 12 Announcements Announcements No baby yet… No baby yet… Fifteen done. Fifteen done. Please read Class Announcements.
CSC 212 Vectors, Lists, & Sequences. Announcement Daily quizzes accepted electronically only  Submit via one or other Dropbox  also accepted,
CSSE221: Software Dev. Honors Day 10 Announcements Announcements Fifteen due Monday 11:59 pm. Monday will be a workday. Fifteen due Monday 11:59 pm. Monday.
CSSE221: Software Dev. Honors Day 4 Pass in Runtime Assignment now to assistants Pass in Runtime Assignment now to assistants Announcements Announcements.
CSSE221: Software Dev. Honors Day 2 Announcements Announcements Homework due now Homework due now Any problems committing JavaEyes to Subversion? Any problems.
CS 106 Introduction to Computer Science I 12 / 11 / 2006 Instructor: Michael Eckmann.
CSSE221: Software Dev. Honors Day 5 Announcements Announcements Homework 2 written portion due now Homework 2 written portion due now You survived the.
CS 206 Introduction to Computer Science II 10 / 26 / 2009 Instructor: Michael Eckmann.
CSSE221: Software Dev. Honors Day 23 Announcements: Announcements: Pass in yesterday’s capsule quiz Pass in yesterday’s capsule quiz Homework 7 electronic.
Lists and the Collection Interface Chapter 4. Chapter 4: Lists and the Collection Interface2 Chapter Objectives To become familiar with the List interface.
CSSE221: Software Dev. Honors Day 7 Announcements Announcements HW2 and inheritance quiz returned now. HW2 and inheritance quiz returned now. Solutions.
Fall 2007CS 2251 Lists and the Collection Interface Chapter 4.
CSSE221: Software Dev. Honors Day 11 Pass in HW4 now Pass in HW4 now Fifteen due 11:59pm Fifteen due 11:59pm Announcements Announcements Questions on Fifteen?
Queues Chapter 6. Chapter 6: Queues2 Chapter Objectives To learn how to represent a waiting line (queue) and how to use the methods in the Queue interface.
CSSE221: Software Dev. Honors Day 14 Announcements Announcements Pass in Homework 5 now Pass in Homework 5 now Questions on Cars, Trucks, Trains? Questions.
CS 106 Introduction to Computer Science I 12 / 13 / 2006 Instructor: Michael Eckmann.
CSC 212 – Data Structures Lecture 21: IndexList a/k/a Vector, ArrayList.
CSSE221: Software Dev. Honors Day 17 Announcements Announcements Fifteen and CarsTrucksTrains coming back Fifteen and CarsTrucksTrains coming back Note:
Java Collections. Collections, Iterators, Algorithms CollectionsIteratorsAlgorithms.
Please close your laptops and turn off and put away your cell phones, and get out your note-taking materials. Today’s daily 5-minute quiz will be given.
COMP 121 Week 14: Queues. Objectives Learn how to represent a queue Learn how to use the methods in the Queue interface Understand how to implement the.
Implementing Stacks Ellen Walker CPSC 201 Data Structures Hiram College.
Linked Lists. RHS – SOC 2 Linked lists We can already store collec- tions of objects in arrays and array lists – why would we need other data structures…?
CSC 212 – Data Structures Lecture 20: Deques. Question of the Day How did the clerk know that the man telling the following story is a fraud? I hope you.
Lists Based on content from: Java Foundations, 3rd Edition.
Information and Computer Sciences University of Hawaii, Manoa
Analysis of Algorithms continued Recursion.  On Capstone Project? ◦ Automatic extension to Monday morning ◦ If a team member does not wish to join the.
CS 46B: Introduction to Data Structures July 9 Class Meeting Department of Computer Science San Jose State University Summer 2015 Instructor: Ron Mak
Introduction to Data Structures
LinkedList Many slides from Horstmann modified by Dr V.
CSS446 Spring 2014 Nan Wang  Java Collection Framework ◦ LinkedList ◦ Set ◦ Map 2.
HIT2037- HIT6037 Software Development in Java 22 – Data Structures and Introduction.
Queue FIFO (First In First Out) Java Doc peek, element offer poll, add
Principles of Computer Science I Honors Section Note Set 1 CSE 1341 – H 1.
Correction of quizzes. ADTs and implementations Hash tables Graphs.
1 Daily Announcements CS 202, Spring 2007 Aaron Bloomfield.
COP INTERMEDIATE JAVA Data Structures. A data structure is a way of organizing a collection of data so that it can be manipulated effectively. A.
Standard Template Library The Standard Template Library was recently added to standard C++. –The STL contains generic template classes. –The STL permits.
Introduction to Management
1 Lecture 14: Queues Lecturer: Santokh Singh CompSci 105 SS 2005 Principles of Computer Science.
Question of the Day  Two English words change their pronunciation when their first letter is capitalized. What are they?
LECTURE 27: DEQUES CSC 212 – Data Structures. Roses are red and violets are blue Implement push, pop, & top And you’re a Stack too! Stack & ADT Memory.
Collections Mrs. C. Furman April 21, Collection Classes ArrayList and LinkedList implements List HashSet implements Set TreeSet implements SortedSet.
CSC 212 Sequences & Iterators. Announcements Midterm in one week  Will cover through chapter 5 of book  Midterm will be open book, open note (but, closed.
Understanding General Software Development Lesson 3.
Week 2 - Friday.  What did we talk about last time?  Computing Big Oh.
© 2011 Pearson Addison-Wesley. All rights reserved 8 B-1 Chapter 8 (continued) Queues.
List Interface and Linked List Mrs. Furman March 25, 2010.
April 27, 2017 COSC Data Structures I Review & Final Exam
Data Structures I Collection, List, ArrayList, LinkedList, Iterator, ListNode.
Prefix notation in action
Double-Ended Queues Chapter 5.
Marcus Biel, Software Craftsman
Csc 2720 Data structure Instructor: Zhuojun Duan
structures and their relationships." - Linus Torvalds
Linked Lists.
Collections Framework
Queues cont. Chapter 8 © 2011 Pearson Addison-Wesley. All rights reserved.
structures and their relationships." - Linus Torvalds
Queues.
Presentation transcript:

CSSE221: Software Dev. Honors Day 13 Announcements Announcements Contractions throughout the night… Contractions throughout the night… Late day assignments passed in now. Late day assignments passed in now. Homework 5 due Monday in class Homework 5 due Monday in class Cars, Trucks, Trains due Monday night, but no class time allotted on Monday to work on. Cars, Trucks, Trains due Monday night, but no class time allotted on Monday to work on. Questions on either? Questions on either? Section 1: we’ll defer extra time for iterator work until later in the class. Section 1: we’ll defer extra time for iterator work until later in the class.

This week: CarsTrucksTrains Monday: Monday: Project workday Project workday Tuesday: Tuesday: Generics (capsule) Generics (capsule) Iterators Iterators Thursday: Thursday: Lists (capsule) Lists (capsule) Implementation of linked lists deferred. Implementation of linked lists deferred. Discussion of Exam 1 Discussion of Exam 1

List Interface (extends Collection) A List is an ordered collection, items accessible by position. Here, ordered does not mean sorted. A List is an ordered collection, items accessible by position. Here, ordered does not mean sorted. interface java.util.List interface java.util.List User may insert a new item at a specific position. User may insert a new item at a specific position. Some important List methods: Some important List methods:

Iterators An extension, ListIterator (see: ), adds : ListIterator ’s remove() method deletes the last element accessed by next or previous. Use list.listIterator() or list.listIterator(int index) to get one.

ArrayList implementation of the List Interface Store items contiguously in a "growable" array. Store items contiguously in a "growable" array. Looking up an item by index takes constant time. Looking up an item by index takes constant time. Insertion or removal of an object takes linear time in the worst case and on the average (why?). Insertion or removal of an object takes linear time in the worst case and on the average (why?). Remember your big-Oh? Remember your big-Oh? If Comparable list items are kept in sorted order in the ArrayList, finding an item takes log N time (our search capsule will demo how in a couple weeks). If Comparable list items are kept in sorted order in the ArrayList, finding an item takes log N time (our search capsule will demo how in a couple weeks). Acceptable if we most often add to the end of the array. Acceptable if we most often add to the end of the array.

Stores items (non-contiguously) in nodes; each contains a reference to the next node. Stores items (non-contiguously) in nodes; each contains a reference to the next node. Lookup by index is linear time (worst, average). Lookup by index is linear time (worst, average). Insertion or removal is constant time once we have found the location. Insertion or removal is constant time once we have found the location. Insert A4 after A1. Insert A4 after A1. Even if Comparable list items are kept in sorted order, finding an item still takes linear time. Even if Comparable list items are kept in sorted order, finding an item still takes linear time. Implementing these is fun, will defer until later Implementing these is fun, will defer until later LinkedList implementation of the List Interface

LinkedList additional methods Special methods to manipulate the ends of a list because it’s cheap to do: Special methods to manipulate the ends of a list because it’s cheap to do: addFirst(E e) [Stacks call it push()] addLast(E e) [Queues call it offer()] E getFirst() [peek() or peekFirst] E getLast() [peekLast()] E removeFirst() [pop() in Stacks, poll() in Queues] E removeLast() [pollLast()]

Which list to use?

OperationArrayListLinkedList Random access Accessing front or rear Insert in front Insert in middle Insert in back

Which list to use? OperationArrayListLinkedList Random access O(1)O(n) Accessing front or rear O(1)O(1) Insert in front O(n)O(1) Insert in middle O(n) O(1) once found Insert in back O(1) average (O(n) resizing occurs rarely) O(1)

Exam 1: Thursday, October 4 Kinds of things covered on exam: Kinds of things covered on exam: Material up through lists Material up through lists Classwork and class discussions. Classwork and class discussions. All assigned readings (on the schedule page) up through the class day before the exam. Basic ideas from all reading, more detail on sections we’ve reinforced in class or written homework. All assigned readings (on the schedule page) up through the class day before the exam. Basic ideas from all reading, more detail on sections we’ve reinforced in class or written homework. Homeworks 1-5. Homeworks 1-5. Programming problems: JavaEyes, BigRational, BallWorlds, Fifteen, CarsTrucks, Trains. Programming problems: JavaEyes, BigRational, BallWorlds, Fifteen, CarsTrucks, Trains.

Format Part I will be written: short answer, explain, predict the output, determine the runtime, etc. Part I will be written: short answer, explain, predict the output, determine the runtime, etc. Part II Part II There will be one or more short problems that require you to write a small amount of code and get it working on your computer, and submit it to your personal repository. There will be one or more short problems that require you to write a small amount of code and get it working on your computer, and submit it to your personal repository.

Allowed Resources for Exam 1 Part I will allow the use of handwritten notes: Part I will allow the use of handwritten notes: One side of a single sheet of 8.5 x 11 paper. One side of a single sheet of 8.5 x 11 paper. Preparing the paper helps more than using it during the exam. Preparing the paper helps more than using it during the exam.

Allowed Resources For Part II, you may use your textbook, class notes, anything that is already on your computer before 7:30 am on Thursday, and the following network resources: For Part II, you may use your textbook, class notes, anything that is already on your computer before 7:30 am on Thursday, and the following network resources: Any public CSSE 221 material on ANGEL. Any public CSSE 221 material on ANGEL. Your personal repository. Your personal repository. Sun's Java pages and the textbook's web pages. Sun's Java pages and the textbook's web pages. Make sure you know how to find the JDK documentation; you may be asked to look up and figure out how to use a class that you have not heard of before. Make sure you know how to find the JDK documentation; you may be asked to look up and figure out how to use a class that you have not heard of before. Any of the Safari Tech Books on-line books. Any of the Safari Tech Books on-line books.

Dis-allowed Resources Of course you may not use IM, IRC, , web pages not listed above, cell phones, PDA’s, or any other means of communication, nor may you access anything written by anyone else. Of course you may not use IM, IRC, , web pages not listed above, cell phones, PDA’s, or any other means of communication, nor may you access anything written by anyone else. You may not place anything on the network, other than in your personal repository You may not place anything on the network, other than in your personal repository

Why are you telling me this now? So you can study and ask questions in class before the exam. So you can study and ask questions in class before the exam.

Project time Make sure you finish the iterator quiz (sec 1 only) Make sure you finish the iterator quiz (sec 1 only) Then you can work on HW5 or CarsTrucksTrains Then you can work on HW5 or CarsTrucksTrains