Lists Chapters Linked Lists Abstract Implementations Storage Leaks Ordered Lists

Size: px
Start display at page:

Download "Lists Chapters Linked Lists Abstract Implementations Storage Leaks Ordered Lists"

Transcription

1 Lists Chapters 8-11 Linked Lists Abstract Implementations Storage Leaks Ordered Lists

2 Data Storage Organisation Three basic implementation techniques for linear data collections Files Arrays Linked Lists properties length direct access append insert update persistent file flexible array fixed linked list flexible schmiedecke 07 Inf2-6-Testing 2

3 Data Structures A data structure is a data storage organisation defined and used by the same class. If there are rules to obey, the data structure must be made private. Example: Sorted list of Strings used as an index table into a list of lists, in this case a lookup construct for first name ocurrences. public class BirthRegister { private BirthEntry [] births = new BirthEntry[10000]; private String[] names = new String[5000]; private BirthEntry[][] refs = new BirthEntry[5000][100]; public void enter(birthentry birth) { births[nextentry] = birth; nextentry++; int index = names.locate(birth.firstname); int ii; for (ii=0; ii<100; ii++) if (refs[index][ii]==null) break; refs[index][ii]=birth; schmiedecke 07 Inf2-6-Testing 3

4 Abstract Data Types Implementation of functionality, Data structure is hidden (encapsulated) and exchangeable, General or generic element Type. Contains a private data structure. Exports access and modification methods for the data structure, Usually defined by an interface Examples Typical data structure: Stack, Queue, Set, Bag Linear List Symbol Table Map Lookup Tables Sorted List Hierarchical Structures Tree Arbitrary Structure Graph, Matrix Text Linear List, Tree Binary Tree Tree, Matrix, List,... schmiedecke 07 Inf2-6-Testing 4

5 Flexible Lists Very often, the required size of a list cannot be foreseen. So we need to start with an initial size and provide an extension mechanism, hidden or visible. Normally, extension is done implicitly. schmiedecke 07 Inf2-6-Testing 5

6 Flexible Arrays Flexible Arrays have an initial size - usualy set by a constructor parameter and an increment - either fixed - or adaptive to the array growth (e.g. doubling its size) If a data entry is no longer possible, a new array is defined and the array content is copied. We have seen that doubling the size is the most efficient way of adapting the array size. schmiedecke 07 Inf2-6-Testing 6

7 Implement a Flexible Array with Insertion public class FlexibleArray implements BasicList { private Object [] list; private int count = 0; public FlexibleArray() { this(100); public FlexibleArray(int initialcapacity) { list = new Object[initialCapacity]; public Object get(int index) { return list[index]; public void set(int index, Object value) { list[index] = value; public void add(object value) { ensurecapacity(count+1); list[count] = value; count++; schmiedecke 07 Inf2-6-Testing 7

8 public void add(int index, Object value) { ensurecapacity(count+1); for (int i=count; i>index; i--) list[i] = list[i-1]; list[index] = value; count++; public Object remove(int index) { Object result = list[index]; count--; for (int i=index; i<count; i++) list[i] = list[i+1]; public int size() { return count; schmiedecke 07 Inf2-6-Testing 8

9 Capacity Increment private int capacityincrement; // set in constructor! public void ensurecapacity (int mincapacity) { if (list.length >= mincapacity) return; int newlength = list.length; while (newlength < mincapacity) newlength += capacityincrement; Object[] newlist = new Object[newLength]; for (int i=0; i<count; i++) newlist[i] = list[i]; list = newlist; There are more eleborate strategies for the increment, e.g. doubling the size every time... schmiedecke 07 Inf2-6-Testing 9

10 Dynamic Lists Flexible Arrays adapt their size to the requirements - requires data copying - works only in lumps - insertion and removal require copying, too. Linked Lists adapt thier size immediately - no copying required. schmiedecke 07 Inf2-6-Testing 10

11 Linked Lists Info1 Info2 Info4 Info5 null Basic operations: addafter removeafter getnext get/setvalue Info3 schmiedecke 07 Inf2-6-Testing 11

12 Type Node public class Node { private Node next; private Element info; public Node() { public Node(Node next, Element info) { this.next = next; this.info = info; public node getnext() { return this.next(); public void addafter(element info) { this.next = new Node(this.next, info); public Element removeafter() { Element info = this.next.info; // NullPointerException! this.next = this.next.next; return info; schmiedecke 07 Inf2-6-Testing 12

13 Linked Stack top null public class Stack { private Node top; public void push(element info) { top = new Node(top, info); public Element pop() throws EmptyException { try { Element info = top.getinfo(); top = top.next(); return info; catch (NullPointerException e) { throw new EmptyException(); schmiedecke 07 Inf2-6-Testing 13

14 first Linked Queue last null null public class Queue { private Node first, last; public void add(element info) { if (last==null) first = last = new Node(null, info); else { last.addafter(info); last = last.getnext(); public Element remove() throws EmptyException { try { Element info = first.getinfo(); first = first.getnext(); if (first==null) last = null; return info; catch (NullPointerException e) { throw new EmptyException(); schmiedecke 07 Inf2-6-Testing 14

15 Anchor Nodes First element requires extra treatment: - predecessor is not a node, but a variable - inserting and removing means changing the variable rather than the predecessors "next" attribute - so addafter and removeafter cannot be applied to it Simplify situation by creating an "artificial" predecessor - call it "anchor node" anchor node will never be removed null schmiedecke 07 Inf2-6-Testing 15

16 top Linked Stack with Anchor Node null public class Stack { private Node top = new Node(null, null); // Anchor node public void push(element info) { top.addafter(info); public Element pop() throws EmptyException { try { return top.removeafter() catch (NullPointerException e) { throw new EmptyException(); schmiedecke 07 Inf2-6-Testing 16

17 Linked Queue with Anchor Node first last null null public class Queue { private Node first=new Node(null,null), last; public Queue() { last = first; // start at anchor node public void add(element info) { last.addafter(info); last = last.getnext(); public Element remove() throws EmptyException { try { return first.removeafter(); catch (NullPointerException e) { throw new EmptyException(); schmiedecke 07 Inf2-6-Testing 17

18 Doubly Linked List info info info info Basic Operations: info addbefore / addafter removebefore / removeafter getnext / get Previous get/setinfo Free navigation, anchor node still useful. schmiedecke 07 Inf2-6-Testing 18

19 Implement List using a Linked List large interface: isempty(), getfirst(), getlast(), addfirst(), addlast(), removefirst(),..., contains(), indexof(),... many conveniance methods all can be mapped to the following basic set of methods: - int size() - void add(int index, Object value) - Object remove(int index) - Object get(int index) schmiedecke 07 Inf2-6-Testing 19

20 Start with an Abstract Implementation public abstract class AbstractList extends List { // size, add, remove, get are left abstract public boolean isempty() { return size()==0; public void addfirst(object value) { add(0, value); public void addlast(object value) { add(size()-1, value); public Object getfirst() { return get(0); public Object getlast() { return get(size()-1); public Object removefirst() { return remove(0); public Object removelast() { return remove(size()-1); public void add(object value) { addlast(value); public Object remove() { return removelast(); public Object get() { return getlast(); public boolean contains(object value) { return indexof(value)!= -1; public int indexof(object value) { for (int i=0; i<size()-1; i++) if (get(i)==value) return i; return 1; schmiedecke 07 Inf2-6-Testing 20

21 Implement a Basic Linked List public class BasicLinkedList { private Node anchor = new Node(null, null); private int size = 0; private Node getnode(int index) { if (index>size-1) throw new IndexOutOfBoundsException(); Node current = anchor; for(int i=0; i<=index; i++) current = current.next; return current; public Object get(int index) { return getnode(index).value; public void add (int index, Object value) { getnode(index-1).addafter(value); size++; public Object remove(int index) { Object result = getnode(index-1).removeafter(); size--; return result; schmiedecke 07 Inf2-6-Testing 21

22 public int indexof(object value) { if (size==0) throw new EmptyException(); Node current = start.next; for (int i=0; i<size; i++) { if (current.info==value) return i; current = current.next; return 1; // more efficient than method in abstract class // required for iterators public Node getanchor() { return anchor; schmiedecke 07 Inf2-6-Testing 22

23 Implement a LinkedList public class LinkedList extends AbstractList { private BasicLinkedList list = new BasicLinkedList(); public Object get(int index) { if (index >= size()) throw new IndexOutOfBoundsException(); return list.get(index); public void add(int index, Object value) { list.add(index,value); public Object remove(int index) { return list.remove(index); public int size() { return size; public int indexof(object value) { return list.indexof(value); // use more efficient method public Node getanchor() { list.getanchor(); schmiedecke 07 Inf2-6-Testing 23

24 Add an Iterator public class IterableLinkedList extends LinkedList{ public Iterator iterator() { return new LLIterator(); // define iterator as inner class class LLIterator implements Iterator { private Node current = getanchor(); public boolean hasnext() { return current!= null && current.next!= null; public Object next() { if (!hasnext()) throw new InvalidIteratorError(); current = current.next; return current.info; schmiedecke 07 Inf2-6-Testing 24

25 ListIterator??? A ListIterator can move forward and backwards. So, it is really only appropriate for doubly linked lists! public interface ListIterator <T> { public boolean hasnext(); public boolean hasprevious(); public T next(); public int nextindex(); public T previous(); public int previousindex(); public void add(t element); public void remove(); // remove current public void set(t element); // replace current Usually, linked lists are doubly linked lists! schmiedecke 07 Inf2-6-Testing 25

26 When to Use Linked Lists? Space: - Linked lists don't keep spare space. - Shrink when list shrinks! - But linking requires some extra space. Efficient, if space requirements are not predictable or vary over time. Time: - No random access, always traversal. - But direct insertion/deletion without moving data Efficient for frequent data insertion or deletion. Inefficient for frequent search operations. schmiedecke 07 Inf2-6-Testing 26

27 Beware of Memory Leaks! 24/7 services need to be restarted regularly. Why? They tend to run out of memory. In "older" languages, you cannot simply "create an object", rather - you must explicitly allocate memory to that object - you must explicitly free that memory when the object is discarded. Forgetting to free object space costs memory on the long run schmiedecke 07 Inf2-6-Testing 27

28 But Java is Different In order to avoid memory leaks, Java objects are freed implicitly by a garbage collector. Simple rule: object has no more references discard. object cannot be freed schmiedecke 07 Inf2-6-Testing 28

29 Linked Structures Always present a danger of memory leaks. even in Java... Be very careful! Delete references manually, if you are not sure that they "disappear" automatically. schmiedecke 07 Inf2-6-Testing 29

30 Local Objects...will "survive" their context if passed to a lasting reference. private int[] temp; public void m1(int[] x) { x = new int[100]; temp = x; call by: m1(myarray); m1(new int[50]); public int[] m2() { int[] local = new int[200]; return local; schmiedecke 07 Inf2-6-Testing 30

31 Example: Look for "Petersen" Enumeration Strategies: Stack vs. Queue Meier Jessen Petersen Hansen Krüger Nielsen Ulldall Clausen Traverse by levels: Add root to queue Klausen Lehmann Müller while queue not empty and target not found: remove node, add subnodes to queue Peters Sanders Traverse by subtrees: Add node to stack; if (target found) return; if (hasleft subtree)traverse left subtree; if (hasright subtree) traverse right subtree; schmiedecke pop; 07 Inf2-6-Testing 31

32 The Coins Game Five Coins of different sizes, ordered upward on the left end of a 5 square board. Aim: move coins to the right end, reversing their order. Use minimum number of moves. Coins may move 1 step in either direction.. Coins may be stacked, but only smaller on bigger ones. Only top of stack coin can move Queue minimum number of moves. WHY? While not finished: Add config to queue; remove config from queue; Add all legal subsequent configs to queue. schmiedecke 07 Inf2-6-Testing 32

33 Ordered Lists Primitive type elements are sorted according to the greater operator > Object elements are sorted using compareto, provided by - the element type, if it implements Comparable - a Comparator object passed to the sorting operation or provided by the List type instance. Two main tasks - sorting a list - keeping a list sorted under modification schmiedecke 07 Inf2-6-Testing 33

34 Implementation Choices: Array List Sorting: - Array provides direct access - use any one of the sorting algorithms Inserting - find insertion point using binary search - possibly extend the array - move down bottom part of the array - insert new value Deleting - possibly, find element using binary search - move up bottom part of the array schmiedecke 07 Inf2-6-Testing 34

35 Implementation Choices Linked List Sorting: - sort by traversing an increasing portion in order to insert current element (insertion sort) - directly insert element Inserting - traverse until position is found - directly insert element Deleting - possibly, traverse to locate element - directly remove element. schmiedecke 07 Inf2-6-Testing 35

36 Implementation Choices Index Tables Organisation: - main list with complex entries - may be multi-dimensional or multiple lists Sorting - Instead of sorting the main list - create an int array of identical length with entries 0..n: an index table - sort the index table according to main list entries - You can hold multiple independant index tables for multiple criteria. Inserting - Add new entry to the end of the main list - resort or invalidate index tables Deleting - set main list entry invalid - compactify main list before the next index table update schmiedecke 07 Inf2-6-Testing 36

37 Index Lookup "Find all patients named "Schmiedecke". Key sorting is not helpful, because we are looking for a record field! For a list - create an index (table) for the name field of the PatientRecord - and keep it sorted - You can create independant indexes for all other record fields! Patient Schmiedecke Patient Jeffers sort Patient Andresen Patient Schmiedecke so the only data moved during sorting are small integers index for "name" schmiedecke 07 Inf2-6-Testing 37

38 Working with an index: In order to enter a record "Schmiedecke" find entry point for "Schmiedecke" in nameindex: private int nameentrypoint(string name) { for (int i=0; i<nameindex.length; i++) { if (table[nameindex[i]] == null) traverse table (table[nameindex[i]].name.greater(name) guided by { return i; nameindex return nameindex.length; // watch out, table is full! // rather use binsearch for efficient lookup!!! Note: the "Schmiedecke" record can be entered in any place in table, e.g. at index 238. This reference index, 238, will be stored innameindex[i], after moving subsequent entries down thenameindex table. schmiedecke 07 Inf2-6-Testing 38

39 Notice on Key Sorting To avoid moving full PatientRecords in order to keep the table key-sorted, you can create an additional sorted index for the key! Note: This technique is standard in database implementations. In relational databases, the user can decide on additional indexes for frequent search criteria. schmiedecke 07 Inf2-6-Testing 39

40 Improving Data Access PatientRecord is a nice application type. But accessing data requires time due to indirection: - it is a reference type containing references - e.g. a name is accessed as table[i].name Column operations like - initializing a column - deleting a column - updating a column require iterating through all PatientRecords. Organize table as array or list of columns rather than a list of records schmiedecke 07 Inf2-6-Testing 40

41 Table as List of Columns TKK /02/1986 Sandmann Sepp 01/05/2007 BKK /06/1999 Schneemann Jutta 12/07/2005 BEK /12/1944 Wassermann Horst 01/06/2007 Table implemented as list of columns. Each column has its data type. Each column may have a name. A PatientRecord is a set of column values with identical index. If you have looked up a column entry, e.g. "Schneemann", its index gives access to the entire PatientRecord. schmiedecke 07 Inf2-6-Testing 41

42 Implementation public class PatientTable { Vector<String> insuranceno = new Vector<String>(); Vector<Date> dateofbirth = new Vector<Date>(); Vector <String> name = new Vector<String>(); Vector<String> firstname = new Vector<String>(); Vector<BloodGroup> bloodgroup = new Vector<BloodGroup>(); Vector<Date> insurancecardread = new Vector<Date>(); Vector[] table = {insuranceno, dateofbirth, name, firstname, bloodgroup, insurancecardread ; schmiedecke 07 Inf2-6-Testing 42

43 Implementation public PatientRecord getpatient(string insurancenumber) { int index = lookupkey(insurancenumber); // using keyindex if (index<0)return null; // not found return new PatientRecord(insuranceNo.get(index), dateofbirth.get(index), name.get(index), firstname.get(index), bloodgroup.get(index), insurancecardread.get(index)); private int lookupkey(string key){ // returns -1 as code for "not found" for (int i=0; i<insuranceno.size(); i++) { if (insuranceno.get(keyindex[i]).equals(key)) return i; if (insuranceno.get(keyindex[i]).greater(key)) return -1; // lookupname, lookupbloodgroup, etc. similar // but use Binsearch instead of linear search!! schmiedecke 07 Inf2-6-Testing 43

44 So, these were the simple, linear data structures. There are some more interesting ones to come, e.g. trees

Java Collections. Readings and References. Collections Framework. Java 2 Collections. References. CSE 403, Winter 2003 Software Engineering

Java Collections. Readings and References. Collections Framework. Java 2 Collections. References. CSE 403, Winter 2003 Software Engineering Readings and References Java Collections References» "Collections", Java tutorial» http://java.sun.com/docs/books/tutorial/collections/index.html CSE 403, Winter 2003 Software Engineering http://www.cs.washington.edu/education/courses/403/03wi/

More information

Topic #9: Collections. Readings and References. Collections. Collection Interface. Java Collections CSE142 A-1

Topic #9: Collections. Readings and References. Collections. Collection Interface. Java Collections CSE142 A-1 Topic #9: Collections CSE 413, Autumn 2004 Programming Languages http://www.cs.washington.edu/education/courses/413/04au/ If S is a subtype of T, what is S permitted to do with the methods of T? Typing

More information

Java Collections. Readings and References. Collections Framework. Java 2 Collections. CSE 403, Spring 2004 Software Engineering

Java Collections. Readings and References. Collections Framework. Java 2 Collections. CSE 403, Spring 2004 Software Engineering Readings and References Java Collections "Collections", Java tutorial http://java.sun.com/docs/books/tutorial/collections/index.html CSE 403, Spring 2004 Software Engineering http://www.cs.washington.edu/education/courses/403/04sp/

More information

CS/CE 2336 Computer Science II

CS/CE 2336 Computer Science II CS/CE 2336 Computer Science II UT D Session 11 OO Data Structures Lists, Stacks, Queues Adapted from D. Liang s Introduction to Java Programming, 8 th Ed. 2 What is a Data Structure? A collection of data

More information

Implementing a List in Java. CSE 143 Java. Just an Illusion? List Interface (review) Using an Array to Implement a List.

Implementing a List in Java. CSE 143 Java. Just an Illusion? List Interface (review) Using an Array to Implement a List. Implementing a List in Java CSE 143 Java List Implementation Using Arrays Reading: Ch. 13 Two implementation approaches are most commonly used for simple lists: Arrays Linked list Java Interface List concrete

More information

List ADT. B/W Confirming Pages

List ADT. B/W Confirming Pages wu3399_ch8.qxd //7 :37 Page 98 8 List ADT O b j e c t i v e s After you have read and studied this chapter, you should be able to Describe the key features of the List ADT. the List ADT using an array

More information

CS231 - Spring 2017 Linked Lists. ArrayList is an implementation of List based on arrays. LinkedList is an implementation of List based on nodes.

CS231 - Spring 2017 Linked Lists. ArrayList is an implementation of List based on arrays. LinkedList is an implementation of List based on nodes. CS231 - Spring 2017 Linked Lists List o Data structure which stores a fixed-size sequential collection of elements of the same type. o We've already seen two ways that you can store data in lists in Java.

More information

Linked Lists. Chapter 12.3 in Savitch

Linked Lists. Chapter 12.3 in Savitch Linked Lists Chapter 12.3 in Savitch Preliminaries n Arrays are not always the optimal data structure: q An array has fixed size needs to be copied to expand its capacity q Adding in the middle of an array

More information

Array Lists Outline and Required Reading: Array Lists ( 7.1) CSE 2011, Winter 2017, Section Z Instructor: N. Vlajic

Array Lists Outline and Required Reading: Array Lists ( 7.1) CSE 2011, Winter 2017, Section Z Instructor: N. Vlajic rray Lists Outline and Required Reading: rray Lists ( 7.) CSE 20, Winter 207, Section Z Instructor: N. Vlajic Lists in Everyday Life 2 List convenient way to organize data examples: score list, to-do list,

More information

Implementing a List in Java. CSE 143 Java. List Interface (review) Just an Illusion? Using an Array to Implement a List.

Implementing a List in Java. CSE 143 Java. List Interface (review) Just an Illusion? Using an Array to Implement a List. Implementing a List in Java CSE 143 Java List Implementation Using Arrays Reading: Ch. 22 Two implementation approaches are most commonly used for simple lists: Arrays Linked list Java Interface List concrete

More information

Implementing Lists, Stacks, Queues, and Priority Queues

Implementing Lists, Stacks, Queues, and Priority Queues Implementing Lists, Stacks, Queues, and Priority Queues CSE260, Computer Science B: Honors Stony Brook University http://www.cs.stonybrook.edu/~cse260 1 Objectives To design common features of lists in

More information

Generics Collection Framework

Generics Collection Framework Generics Collection Framework Sisoft Technologies Pvt Ltd SRC E7, Shipra Riviera Bazar, Gyan Khand-3, Indirapuram, Ghaziabad Website: www.sisoft.in Email:info@sisoft.in Phone: +91-9999-283-283 Generics

More information

Vector (Java 2 Platform SE 5.0) Overview Package Class Use Tree Deprecated Index Help

Vector (Java 2 Platform SE 5.0) Overview Package Class Use Tree Deprecated Index Help Overview Package Class Use Tree Deprecated Index Help PREV CLASS NEXT CLASS FRAMES NO FRAMES All Classes SUMMARY: NESTED FIELD CONSTR METHOD DETAIL: FIELD CONSTR METHOD Página 1 de 30 Java TM 2 Platform

More information

An Introduction to Data Structures

An Introduction to Data Structures An Introduction to Data Structures Advanced Programming ICOM 4015 Lecture 17 Reading: Java Concepts Chapter 20 Fall 2006 Adapded from Java Concepts Companion Slides 1 Chapter Goals To learn how to use

More information

Data Structure: Lists and Iterators. Instructor: Prof. Young-guk Ha Dept. of Computer Science & Engineering

Data Structure: Lists and Iterators. Instructor: Prof. Young-guk Ha Dept. of Computer Science & Engineering Data Structure: Lists and Iterators 2017 Instructor: Prof. Young-guk Ha Dept. of Computer Science & Engineering Contents Data structures to be covered in this lecture Array lists (aka Vectors) Node lists

More information

Class 26: Linked Lists

Class 26: Linked Lists Introduction to Computation and Problem Solving Class 26: Linked Lists Prof. Steven R. Lerman and Dr. V. Judson Harward 2 The Java Collection Classes The java.util package contains implementations of many

More information

Lists. The List ADT. Reading: Textbook Sections

Lists. The List ADT. Reading: Textbook Sections Lists The List ADT Reading: Textbook Sections 3.1 3.5 List ADT A list is a dynamic ordered tuple of homogeneous elements A o, A 1, A 2,, A N-1 where A i is the i-th element of the list The position of

More information

Linked Lists. Linked List Nodes. Walls and Mirrors Chapter 5 10/25/12. A linked list is a collection of Nodes: item next -3.

Linked Lists. Linked List Nodes. Walls and Mirrors Chapter 5 10/25/12. A linked list is a collection of Nodes: item next -3. Linked Lists Walls and Mirrors Chapter 5 Linked List Nodes public class Node { private int item; private Node next; public Node(int item) { this(item,null); public Node(int item, Node next) { setitem(item);

More information

The Java Collections Framework. Chapters 7.5

The Java Collections Framework. Chapters 7.5 The Java s Framework Chapters 7.5 Outline Introduction to the Java s Framework Iterators Interfaces, Classes and Classes of the Java s Framework Outline Introduction to the Java s Framework Iterators Interfaces,

More information

Lecture 4. The Java Collections Framework

Lecture 4. The Java Collections Framework Lecture 4. The Java s Framework - 1 - Outline Introduction to the Java s Framework Iterators Interfaces, Classes and Classes of the Java s Framework - 2 - Learning Outcomes From this lecture you should

More information

Lecture 12: Doubly Linked Lists

Lecture 12: Doubly Linked Lists Lecture 12: Doubly Linked Lists CS 62 Fall 2018 Alexandra Papoutsaki & William Devanny 1 Doubly Linked List A linked list consisting of a sequence of nodes, starting from a head pointer and ending to a

More information

CSE 143 Lecture 26. Advanced collection classes. (ADTs; abstract classes; inner classes; generics; iterators) read 11.1, 9.6, ,

CSE 143 Lecture 26. Advanced collection classes. (ADTs; abstract classes; inner classes; generics; iterators) read 11.1, 9.6, , CSE 143 Lecture 26 Advanced collection classes (ADTs; abstract classes; inner classes; generics; iterators) read 11.1, 9.6, 15.3-15.4, 16.4-16.5 slides created by Marty Stepp, adapted by Alyssa Harding

More information

Linked List Nodes (reminder)

Linked List Nodes (reminder) Outline linked lists reminders: nodes, implementation, invariants circular linked list doubly-linked lists iterators the Java foreach statement iterator implementation the ListIterator interface Linked

More information

CONTAİNERS COLLECTİONS

CONTAİNERS COLLECTİONS CONTAİNERS Some programs create too many objects and deal with them. In such a program, it is not feasible to declare a separate variable to hold reference to each of these objects. The proper way of keeping

More information

Notes on access restrictions

Notes on access restrictions Notes on access restrictions A source code file MyClass.java is a compilation unit and can contain at most one public class. Furthermore, if there is a public class in that file, it must be called MyClass.

More information

Abstract Data Types - Lists Arrays implementa4on Linked- lists implementa4on

Abstract Data Types - Lists Arrays implementa4on Linked- lists implementa4on Abstract Data Types - Lists Arrays implementa4on Linked- lists implementa4on Lecture 16 Jérôme Waldispühl School of Computer Science McGill University Slides by Mathieu BlancheIe Recap from last lecture

More information

A Linked Structure. Chapter 17

A Linked Structure. Chapter 17 Chapter 17 A Linked Structure This chapter demonstrates the OurList interface implemented with a class that uses a linked structure rather than the array implementation of the previous chapter. The linked

More information

SSJ User s Guide. Package simevents Simulation Clock and Event List Management

SSJ User s Guide. Package simevents Simulation Clock and Event List Management SSJ User s Guide Package simevents Simulation Clock and Event List Management Version: December 21, 2006 This package provides the simulation clock and tools to manage the future events list. These are

More information

Computer Science 210: Data Structures. Linked lists

Computer Science 210: Data Structures. Linked lists Computer Science 210: Data Structures Linked lists Arrays vs. Linked Lists Weʼve seen arrays: int[] a = new int[10]; a is a chunk of memory of size 10 x sizeof(int) a has a fixed size a[0] a[1] a[2]...

More information

CSC 1052 Algorithms & Data Structures II: Lists

CSC 1052 Algorithms & Data Structures II: Lists CSC 1052 Algorithms & Data Structures II: Lists Professor Henry Carter Spring 2018 Recap Collections hold and access elements based on content Order and index no longer considered Comparable elements implement

More information

Announcements. Prelude (2) Prelude (1) Data Structures and Information Systems Part 1: Data Structures. Lecture 6: Lists.

Announcements. Prelude (2) Prelude (1) Data Structures and Information Systems Part 1: Data Structures. Lecture 6: Lists. Announcements MODULE WEB-SITE: http://www.csc.liv.ac.uk/ michele/teaching/comp102/comp102.html FIRST ASSIGNMENT DEADLINE: Wednesday, February 1st, 14.30, LAB 7 Boxes (late submissions to be left in the

More information

11-1. Collections. CSE 143 Java. Java 2 Collection Interfaces. Goals for Next Several Lectures

11-1. Collections. CSE 143 Java. Java 2 Collection Interfaces. Goals for Next Several Lectures Collections CSE 143 Java Collections Most programs need to store and access collections of data Collections are worth studying because... They are widely useful in programming They provide examples of

More information

Overview of Java ArrayList, HashTable, HashMap, Hashet,LinkedList

Overview of Java ArrayList, HashTable, HashMap, Hashet,LinkedList Overview of Java ArrayList, HashTable, HashMap, Hashet,LinkedList This article discusses the main classes of Java Collection API. The following figure demonstrates the Java Collection framework. Figure

More information

CS 151. Linked Lists, Recursively Implemented. Wednesday, October 3, 12

CS 151. Linked Lists, Recursively Implemented. Wednesday, October 3, 12 CS 151 Linked Lists, Recursively Implemented 1 2 Linked Lists, Revisited Recall that a linked list is a structure that represents a sequence of elements that are stored non-contiguously in memory. We can

More information

Programming II (CS300)

Programming II (CS300) 1 Programming II (CS300) Chapter 07: Linked Lists MOUNA KACEM mouna@cs.wisc.edu Spring 2019 Linked Lists 2 Introduction Linked List Abstract Data Type SinglyLinkedList ArrayList Keep in Mind Introduction:

More information

Java Collections. Wrapper classes. Wrapper classes

Java Collections. Wrapper classes. Wrapper classes Java Collections Engi- 5895 Hafez Seliem Wrapper classes Provide a mechanism to wrap primitive values in an object so that the primitives can be included in activities reserved for objects, like as being

More information

Java Collections. Engi Hafez Seliem

Java Collections. Engi Hafez Seliem Java Collections Engi- 5895 Hafez Seliem Wrapper classes Provide a mechanism to wrap primitive values in an object so that the primitives can be included in activities reserved for objects, like as being

More information

The Collections API. Lecture Objectives. The Collections API. Mark Allen Weiss

The Collections API. Lecture Objectives. The Collections API. Mark Allen Weiss The Collections API Mark Allen Weiss Lecture Objectives To learn how to use the Collections package in Java 1.2. To illustrate features of Java that help (and hurt) the design of the Collections API. Tuesday,

More information

Java Collections Framework: Interfaces

Java Collections Framework: Interfaces Java Collections Framework: Interfaces Introduction to the Java Collections Framework (JCF) The Comparator Interface Revisited The Collection Interface The List Interface The Iterator Interface The ListIterator

More information

The Java Collections Framework and Lists in Java Parts 1 & 2

The Java Collections Framework and Lists in Java Parts 1 & 2 The Java Collections Framework and Lists in Java Parts 1 & 2 Chapter 9 Chapter 6 (6.1-6.2.2) CS 2334 University of Oklahoma Brian F. Veale Groups of Data Data are very important to Software Engineering

More information

Doubly LinkedList is Symmetrical! LinkedList Efficiency. Monday, April 8, 13. insert insert remove remove remove walk

Doubly LinkedList is Symmetrical! LinkedList Efficiency. Monday, April 8, 13. insert insert remove remove remove walk How Can We Improve the State of Experimental Evaluation in Computer Siene Peter Sweeney IBM Researh, TJ Watson Friday, April 12, 12:00 Kendade 307 1 Doubly LinkedList is Symmetrial! insert insert remove

More information

Use of the ArrayList class

Use of the ArrayList class Use of the ArrayList class The ArrayList class is very similar to the Vector class. It also manages a collection of objects, and as the name indicates, does so with an array implementation. This is also

More information

EXAMINATIONS 2015 COMP103 INTRODUCTION TO DATA STRUCTURES AND ALGORITHMS

EXAMINATIONS 2015 COMP103 INTRODUCTION TO DATA STRUCTURES AND ALGORITHMS T E W H A R E W Ā N A N G A O T E Student ID:....................... Ū P O K O O T E I K A A M Ā U I VUW VICTORIA U N I V E R S I T Y O F W E L L I N G T O N EXAMINATIONS 2015 TRIMESTER 2 COMP103 INTRODUCTION

More information

엄현상 (Eom, Hyeonsang) School of Computer Science and Engineering Seoul National University

엄현상 (Eom, Hyeonsang) School of Computer Science and Engineering Seoul National University 엄현상 (Eom, Hyeonsang) School of Computer Science and Engineering Seoul National University C O P Y R I G H T S 2 0 1 5 E O M, H Y E O N S A N G A L L R I G H T S R E S E R V E D - Containers - About Containers

More information

Arrays organize each data element as sequential memory cells each accessed by an index. data data data data data data data data

Arrays organize each data element as sequential memory cells each accessed by an index. data data data data data data data data 1 JAVA PROGRAMMERS GUIDE LESSON 1 File: JGuiGuideL1.doc Date Started: July 10, 2000 Last Update: Jan 2, 2002 Status: proof DICTIONARIES, MAPS AND COLLECTIONS We have classes for Sets, Lists and Maps and

More information

Linked List. ape hen dog cat fox. tail. head. count 5

Linked List. ape hen dog cat fox. tail. head. count 5 Linked Lists Linked List L tail head count 5 ape hen dog cat fox Collection of nodes with a linear ordering Has pointers to the beginning and end nodes Each node points to the next node Final node points

More information

Lecture 6: ArrayList Implementation

Lecture 6: ArrayList Implementation Lecture 6: ArrayList Implementation CS 62 Fall 2018 Alexandra Papoutsaki & William Devanny 1 Programming Assignment Weak AI/Natural Language Processing: Generate text by building frequency lists based

More information

CS 307 Final Spring 2008

CS 307 Final Spring 2008 Points off 1 2 3 4 5 Total off Net Score CS 307 Final Spring 2008 Name UTEID login name Instructions: 1. Please turn off your cell phones. 2. There are 5 questions on this test. 3. You have 3 hours to

More information

Review: List Implementations. CSE 143 Java. Links. A Different Strategy: Lists via Links. Linked Links. CSE143 Au List

Review: List Implementations. CSE 143 Java. Links. A Different Strategy: Lists via Links. Linked Links. CSE143 Au List Review: Implementations CSE 143 Java ed s Reading: Ch. 23 The external interface is already defined Implementation goal: implement methods efficiently Array approach: use an array with extra space internally

More information

Abstract Data Types - Lists Arrays implementation Linked-lists implementation

Abstract Data Types - Lists Arrays implementation Linked-lists implementation Abstract Data Types - Lists Arrays implementation Linked-lists implementation Lecture 17 Jérôme Waldispühl School of Computer Science McGill University From slides by Mathieu Blanchette Abstract data types

More information

COMP200 GENERICS. OOP using Java, from slides by Shayan Javed

COMP200 GENERICS. OOP using Java, from slides by Shayan Javed 1 1 COMP200 GENERICS OOP using Java, from slides by Shayan Javed 2 ArrayList and Java Generics 3 Collection A container object that groups multiple objects 4 Collection A container object that groups multiple

More information

Te Whare Wananga o te Upoko o te Ika a Maui EXAMINATIONS 2003 END-YEAR COMP 103. Data Structures and Algorithms

Te Whare Wananga o te Upoko o te Ika a Maui EXAMINATIONS 2003 END-YEAR COMP 103. Data Structures and Algorithms VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui EXAMINATIONS 2003 END-YEAR Data Structures and Algorithms Time Allowed: 3 Hours Instructions: There are a total of 180 marks

More information

Generics. IRS W-9 Form

Generics. IRS W-9 Form Generics IRS W-9 Form Generics Generic class and methods. BNF notation Syntax Non-parametrized class: < class declaration > ::= "class" < identifier > ["extends" < type >] ["implements" < type list >]

More information

package weiss.util; // Fig , pg // Fig 6.16,6.17, pg package weiss.util;

package weiss.util; // Fig , pg // Fig 6.16,6.17, pg package weiss.util; package weiss.util; // Fig 6.9-10, pg 192-4. public interface Collection extends java.io.serializable int size( ); boolean isempty( ); boolean contains( Object x ); boolean add( Object x ); boolean remove(

More information

Taking Stock. IE170: Algorithms in Systems Engineering: Lecture 7. (A subset of) the Collections Interface. The Java Collections Interfaces

Taking Stock. IE170: Algorithms in Systems Engineering: Lecture 7. (A subset of) the Collections Interface. The Java Collections Interfaces Taking Stock IE170: Algorithms in Systems Engineering: Lecture 7 Jeff Linderoth Department of Industrial and Systems Engineering Lehigh University January 29, 2007 Last Time Practice Some Sorting Algs

More information

Iterators and Sequences

Iterators and Sequences Iterators and Sequences Iterators and Sequences 1 Iterators An iterator abstracts the process of scanning through a collection of elements It maintains a cursor that sits between elements in the list,

More information

CMPSCI 187: Programming With Data Structures. Lecture #21: Array-Based Lists David Mix Barrington 26 October 2012

CMPSCI 187: Programming With Data Structures. Lecture #21: Array-Based Lists David Mix Barrington 26 October 2012 CMPSCI 187: Programming With Data Structures Lecture #21: Array-Based Lists David Mix Barrington 26 October 2012 Array-Based Lists Comparing Objects: equals and Comparable Lists: Unsorted, Sorted, and

More information

The ArrayList class CSC 123 Fall 2018 Howard Rosenthal

The ArrayList class CSC 123 Fall 2018 Howard Rosenthal The ArrayList class CSC 123 Fall 2018 Howard Rosenthal Lesson Goals Describe the ArrayList class Discuss important methods of this class Describe how it can be used in modeling Much of the information

More information

Week 4, Wednesday (Spring 2015). Dr. Yoder. Sec 051. Page 1 of 5

Week 4, Wednesday (Spring 2015). Dr. Yoder. Sec 051. Page 1 of 5 CS2852 Exam 1 Name: No note-sheets, calculators, or other study aids on this exam. Write your initials at the top of each page except this one. Read through the whole exam before you get started. Have

More information

Appendix A: Interfaces and Classes in the AP Java Subset (AB)

Appendix A: Interfaces and Classes in the AP Java Subset (AB) Appendix A: Interfaces and Classes in the AP Java Subset (AB) class java.lang.object int hashcode() java.lang: interface java.lang.comparable ; class java.lang.integer Integer(int value) int intvalue()

More information

COMP103 Test. 5 Sept, 2007

COMP103 Test. 5 Sept, 2007 Family Name:.......................... Other Names:.......................... ID Number:............................ COMP103 Test 5 Sept, 2007 Instructions Time: 90 minutes. Answer all the questions. There

More information

EXAMINATIONS 2011 Trimester 2, MID-TERM TEST. COMP103 Introduction to Data Structures and Algorithms SOLUTIONS

EXAMINATIONS 2011 Trimester 2, MID-TERM TEST. COMP103 Introduction to Data Structures and Algorithms SOLUTIONS T E W H A R E W Ā N A N G A O T E Ū P O K O O T E I K A A M Ā U I VUW V I C T O R I A UNIVERSITY OF WELLINGTON Student ID:....................... EXAMINATIONS 2011 Trimester 2, MID-TERM TEST COMP103 Introduction

More information

Data Structures and Algorithms

Data Structures and Algorithms Data Structures and Algorithms CS245-2015S-05 Abstract Data Types and Lists David Galles Department of Computer Science University of San Francisco 05-0: Abstract Data Types Recall that an Abstract Data

More information

Section Lists and Sets

Section Lists and Sets Section 10.2 Lists and Sets IN THE PREVIOUS SECTION, we looked at the general properties of collection classes in Java. In this section, we look at some specific collection classes and how to use them.

More information

Programming II (CS300)

Programming II (CS300) 1 Programming II (CS300) Chapter 07: Linked Lists and Iterators MOUNA KACEM mouna@cs.wisc.edu Fall 2018 Linked Lists 2 Introduction Linked List Abstract Data Type General Implementation of the ListADT

More information

COMP 103. Data Structures and Algorithms

COMP 103. Data Structures and Algorithms T E W H A R E W Ā N A N G A O T E Ū P O K O O T E I K A A M Ā U I V I C T O R I A UNIVERSITY OF WELLINGTON EXAMINATIONS 2004 END-YEAR COMP 103 Data Structures and Algorithms Time Allowed: 3 Hours Instructions:

More information

Implementing a List in Java. CSC 143 Java. List Interface (review) Just an Illusion? Using an Array to Implement a List CSC

Implementing a List in Java. CSC 143 Java. List Interface (review) Just an Illusion? Using an Array to Implement a List CSC Implementing a List in Java CSC 143 Java List Implementation Using Arrays Updated with Java 5.0 Generics Reading: Ch. 13 Two implementation approaches are most commonly used for simple lists: Arrays Linked

More information

List ADT. Announcements. The List interface. Implementing the List ADT

List ADT. Announcements. The List interface. Implementing the List ADT Announcements Tutoring schedule revised Today s topic: ArrayList implementation Reading: Section 7.2 Break around 11:45am List ADT A list is defined as a finite ordered sequence of data items known as

More information

CSC 321: Data Structures. Fall 2013

CSC 321: Data Structures. Fall 2013 CSC 321: Data Structures Fall 2013 Lists, stacks & queues Collection classes: List (ArrayList, LinkedList), Set (TreeSet, HashSet), Map (TreeMap, HashMap) ArrayList performance and implementation LinkedList

More information

CS S-05 Abstract Data Types and Lists 1

CS S-05 Abstract Data Types and Lists 1 CS245-2016S-05 Abstract Data Types and Lists 1 05-0: Abstract Data Types Recall that an Abstract Data Type is a definition of a type based on the operations that can be performed on it. An ADT is an interface

More information

EXAMINATIONS 2016 TRIMESTER 2

EXAMINATIONS 2016 TRIMESTER 2 T E W H A R E W Ā N A N G A O T E Ū P O K O O T E I K A A M Ā U I VUW VICTORIA U N I V E R S I T Y O F W E L L I N G T O N EXAMINATIONS 2016 TRIMESTER 2 COMP103 INTRODUCTION TO DATA STRUCTURES AND ALGORITHMS

More information

ITI Introduction to Computing II

ITI Introduction to Computing II index.pdf March 17, 2013 1 ITI 1121. Introduction to Computing II Marcel Turcotte School of Electrical Engineering and Computer Science Version of March 17, 2013 Definitions A List is a linear abstract

More information

Abstract Data Types. Data Str. Client Prog. Add. Rem. Find. Show. 01/22/04 Lecture 4 1

Abstract Data Types. Data Str. Client Prog. Add. Rem. Find. Show. 01/22/04 Lecture 4 1 Abstract Data Types Add Client Prog Rem Find Data Str. Show 01/22/04 Lecture 4 1 Containers Powerful tool for programming data structures Provides a library of container classes to hold your objects 2

More information

Lists and Iterators. CSSE 221 Fundamentals of Software Development Honors Rose-Hulman Institute of Technology

Lists and Iterators. CSSE 221 Fundamentals of Software Development Honors Rose-Hulman Institute of Technology Lists and Iterators CSSE 221 Fundamentals of Software Development Honors Rose-Hulman Institute of Technology Announcements Should be making progress on VectorGraphics. Should have turned in CRC cards,

More information

EXAMINATIONS 2012 Trimester 1, MID-TERM TEST. COMP103 Introduction to Data Structures and Algorithms SOLUTIONS

EXAMINATIONS 2012 Trimester 1, MID-TERM TEST. COMP103 Introduction to Data Structures and Algorithms SOLUTIONS T E W H A R E W Ā N A N G A O T E Ū P O K O O T E I K A A M Ā U I VUW V I C T O R I A UNIVERSITY OF WELLINGTON Student ID:....................... EXAMINATIONS 2012 Trimester 1, MID-TERM TEST COMP103 Introduction

More information

9/26/2018 Data Structure & Algorithm. Assignment04: 3 parts Quiz: recursion, insertionsort, trees Basic concept: Linked-List Priority queues Heaps

9/26/2018 Data Structure & Algorithm. Assignment04: 3 parts Quiz: recursion, insertionsort, trees Basic concept: Linked-List Priority queues Heaps 9/26/2018 Data Structure & Algorithm Assignment04: 3 parts Quiz: recursion, insertionsort, trees Basic concept: Linked-List Priority queues Heaps 1 Quiz 10 points (as stated in the first class meeting)

More information

Generic classes & the Java Collections Framework. *Really* Reusable Code

Generic classes & the Java Collections Framework. *Really* Reusable Code Generic classes & the Java Collections Framework *Really* Reusable Code First, a bit of history Since Java version 5.0, Java has borrowed a page from C++ and offers a template mechanism, allowing programmers

More information

Interfaces, collections and comparisons

Interfaces, collections and comparisons תכנות מונחה עצמים תרגול מספר 4 Interfaces, collections and comparisons Interfaces Overview Overview O Interface defines behavior. Overview O Interface defines behavior. O The interface includes: O Name

More information

January 24, Abstract Data Types (ADTs) An ADT is an abstraction of a data structure.

January 24, Abstract Data Types (ADTs) An ADT is an abstraction of a data structure. Lists CSE 2011 Winter 2007 January 24, 2007 1 Abstract Data Types (ADTs) An ADT is an abstraction of a data structure. An ADT specifies: data stored operations on the data error conditions associated with

More information

DM550 / DM857 Introduction to Programming. Peter Schneider-Kamp

DM550 / DM857 Introduction to Programming. Peter Schneider-Kamp DM550 / DM857 Introduction to Programming Peter Schneider-Kamp petersk@imada.sdu.dk http://imada.sdu.dk/~petersk/dm550/ http://imada.sdu.dk/~petersk/dm857/ ABSTRACT DATATYPES 2 Abstract Datatype (ADT)

More information

EXAMINATIONS 2017 TRIMESTER 2

EXAMINATIONS 2017 TRIMESTER 2 T E W H A R E W Ā N A N G A O T E Ū P O K O O T E I K A A M Ā U I VUW VICTORIA U N I V E R S I T Y O F W E L L I N G T O N EXAMINATIONS 2017 TRIMESTER 2 COMP103 INTRODUCTION TO DATA STRUCTURES AND ALGORITHMS

More information

WITH SOLUTIONS!!! WARNING: THIS COPY CONTAINS SOLUTIONS!!! COMP103 Introduction to Data Structures and Algorithms

WITH SOLUTIONS!!! WARNING: THIS COPY CONTAINS SOLUTIONS!!! COMP103 Introduction to Data Structures and Algorithms T E W H A R E W Ā N A N G A O T E Ū P O K O O T E I K A A M Ā U I VUW V I C T O R I A UNIVERSITY OF WELLINGTON Student ID:....................... EXAMINATIONS 2007 SUMMER TRIMESTER COMP103 Introduction

More information

DM503 Programming B. Peter Schneider-Kamp.

DM503 Programming B. Peter Schneider-Kamp. DM503 Programming B Peter Schneider-Kamp petersk@imada.sdu.dk! http://imada.sdu.dk/~petersk/dm503/! ABSTRACT DATATYPE FOR LISTS 2 List ADT: Specification data are all integers, here represented as primitive

More information

Basic Data Structures

Basic Data Structures Basic Data Structures Some Java Preliminaries Generics (aka parametrized types) is a Java mechanism that enables the implementation of collection ADTs that can store any type of data Stack s1

More information

What is the Java Collections Framework?

What is the Java Collections Framework? 1 of 13 What is the Java Collections Framework? To begin with, what is a collection?. I have a collection of comic books. In that collection, I have Tarzan comics, Phantom comics, Superman comics and several

More information

****** NOTE!! THIS CONTAINS SOLUTIONS ***** TRIMESTER 2

****** NOTE!! THIS CONTAINS SOLUTIONS ***** TRIMESTER 2 T E W H A R E W Ā N A N G A O T E Student ID:....................... Ū P O K O O T E I K A A M Ā U I VUW VICTORIA U N I V E R S I T Y O F W E L L I N G T O N ****** NOTE!! THIS CONTAINS SOLUTIONS *****

More information

CSE 131 Computer Science 1 Module 9a: ADT Representations. Stack and queue ADTs array implementations Buffer ADT and circular lists

CSE 131 Computer Science 1 Module 9a: ADT Representations. Stack and queue ADTs array implementations Buffer ADT and circular lists CSE 11 Computer Science 1 Module 9a: ADT Representations Stack and queue ADTs array implementations Buffer ADT and circular lists Buffer ADT add and remove from both ends»can grow and shrink from either

More information

Array Based Lists. Collections

Array Based Lists. Collections Array Based Lists Reading: RS Chapter 15 1 Collections Data structures stores elements in a manner that makes it easy for a client to work with the elements Specific collections are specialized for particular

More information

Class 32: The Java Collections Framework

Class 32: The Java Collections Framework Introduction to Computation and Problem Solving Class 32: The Java Collections Framework Prof. Steven R. Lerman and Dr. V. Judson Harward Goals To introduce you to the data structure classes that come

More information

Recap. List Types. List Functionality. ListIterator. Adapter Design Pattern. Department of Computer Science 1

Recap. List Types. List Functionality. ListIterator. Adapter Design Pattern. Department of Computer Science 1 COMP209 Object Oriented Programming Container Classes 3 Mark Hall List Functionality Types List Iterator Adapter design pattern Adapting a LinkedList to a Stack/Queue Map Functionality Hashing Performance

More information

Basic Data Structures 1 / 24

Basic Data Structures 1 / 24 Basic Data Structures 1 / 24 Outline 1 Some Java Preliminaries 2 Linked Lists 3 Bags 4 Queues 5 Stacks 6 Performance Characteristics 2 / 24 Some Java Preliminaries Generics (aka parametrized types) is

More information

Solutions to a few of the review problems:

Solutions to a few of the review problems: Solutions to a few of the review problems: Problem 1 The interface Deque can have array based and linked implementations. Partial versions of implementation classes follow. Supply implementations for the

More information

LinkedList Implementation Mini-project intro

LinkedList Implementation Mini-project intro LinkedList Implementation Mini-project intro Turn in your written problems Mini-project Partner Survey: Do it by 4:00 today Reminder: Exam #2 is this Thursday In order to reduce time pressure, you optionally

More information

Lists and the Collection Interface. Based on Koffmann and Wolfgang Chapter 4

Lists and the Collection Interface. Based on Koffmann and Wolfgang Chapter 4 Lists and the Collection Interface Based on Koffmann and Wolfgang Chapter 4 Chapter Outline The List interface Writing an array-based implementation of List Linked list data structures: Singly-linked Doubly-linked

More information

9/16/2010 CS Ananda Gunawardena

9/16/2010 CS Ananda Gunawardena CS 15-121 Ananda Gunawardena A collection (sometimes called a container) is simply an object that groups multiple elements into a single unit. Collections are used to store, retrieve and manipulate data,

More information

Data Structures and Algorithms Notes

Data Structures and Algorithms Notes Data Structures and Algorithms Notes Notes by Winst Course taught by Dr. G. R. Baliga 256-400 ext. 3890 baliga@rowan.edu Course started: September 4, 2012 Last generated: December 18, 2013 Interfaces -

More information

Specifications for the ADT List Ali list provides a way to organize data List of students List of sales List of lists

Specifications for the ADT List Ali list provides a way to organize data List of students List of sales List of lists Abstract Data Type List ADT List Specifications for the ADT List Ali list provides a way to organize data List of students List of sales List of lists A list has first, last, and in between items (the

More information

Chapter 9 Lists. Concepts: The list abstraction Singly linked lists Doubly linked lists Circular lists Vectors as lists

Chapter 9 Lists. Concepts: The list abstraction Singly linked lists Doubly linked lists Circular lists Vectors as lists Chapter 9 Lists Concepts: The list abstraction Singly linked lists Doubly linked lists Circular lists Vectors as lists He s makin a list and checkin it twice! Haven Gillespie IMAGINE YOU ARE TO WRITE A

More information

CS Ananda Gunawardena

CS Ananda Gunawardena CS 15-121 Ananda Gunawardena A collection (sometimes called a container) is simply an object that groups multiple elements into a single unit. Collections are used to store, retrieve and manipulate data,

More information

11/2/ Dynamic Data Structures & Generics. Objectives. Array-Based Data Structures: Outline. Harald Gall, Prof. Dr.

11/2/ Dynamic Data Structures & Generics. Objectives. Array-Based Data Structures: Outline. Harald Gall, Prof. Dr. 12. Dynamic Data Structures & Generics Harald Gall, Prof. Dr. Institut für Informatik Universität Zürich http://seal.ifi.uzh.ch Objectives! Define and use an instance of ArrayList! Describe general idea

More information