Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "CSSE221: Software Dev. Honors Day 13 Announcements Announcements Contractions throughout the night… Contractions throughout the night… Late day assignments."— Presentation transcript:

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

2 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

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

4 Iterators An extension, ListIterator (see: http://72.5.124.55/javase/6/docs/api/java/util/ListIterator.html ), adds : http://72.5.124.55/javase/6/docs/api/java/util/ListIterator.html ListIterator ’s remove() method deletes the last element accessed by next or previous. Use list.listIterator() or list.listIterator(int index) to get one.

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

6 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

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

8 Which list to use?

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

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

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

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

13

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

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

16 Dis-allowed Resources Of course you may not use IM, IRC, email, 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, email, 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

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

18 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


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

Similar presentations


Ads by Google