changing a list There are only two ways to change a linked list:

Slides:



Advertisements
Similar presentations
Inserting a Node into a Specified Position of a Linked List To create a node for the new item newNode = new Node(item); To insert a node between two nodes.
Advertisements

Linked List 1. Introduction to Linked List 2. Node Class 3. Linked List 4. The Bag Class with Linked List.
CHAPTER 7 Queues.
Linked Structures See Section 3.2 of the text.. First, notice that Java allows classes to be recursive, in the sense that a class can have an element.
ليست هاي پيوندي Linked Lists ساختمان داده ها و الگوريتم ها.
Lecture7: Queue Bohyung Han CSE, POSTECH CSED233: Data Structures (2014F)
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.
2014-T2 Lecture 19 School of Engineering and Computer Science, Victoria University of Wellington  Marcus Frean, Lindsay Groves, Peter Andreae, and John.
CSE 143 Lecture 10 Linked List Basics reading: slides created by Marty Stepp
2013-T2 Lecture 18 School of Engineering and Computer Science, Victoria University of Wellington  Marcus Frean, Lindsay Groves, Peter Andreae, and John.
(c) University of Washington16-1 CSC 143 Java Linked Lists Reading: Ch. 20.
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.
2015-T2 Lecture 19 School of Engineering and Computer Science, Victoria University of Wellington  Marcus Frean, Lindsay Groves, Peter Andreae, and John.
slides adapted from Marty Stepp and Hélène Martin
Linked Lists A formal data structure. Linked Lists Collections of data items “lined up in a row” Inserts and deletes can be done anywhere in the list.
Linked Data Structures
Stack: a Linked Implementation
Section 2.6 Linked List StringLog ADT Implementation
The List ADT.
[Chapter 4; Chapter 6, pp ] CSC 143 Linked Lists (cont) [Chapter 4; Chapter 6, pp ]
LinkedIntList(int n) Write a constructor for LinkedIntList that accepts an int n parameter and makes a list of the number from 0 to n new LinkedIntList(3)
Building Java Programs
Doubly Linked List Review - We are writing this code
Sections 8.7 – 8.8 Balancing a Binary Search Tree.
Linked Lists Damian Gordon.
Data Structures 7th Week
Programming Abstractions
COP 3538 Data Structures with OOP
slides created by Marty Stepp
Notes on Assignment 1 Your code will have several classes, most notably the class that represents the entire list data structure, and the class.
Wednesday Questions How do I debug? We love to teach this at IPL/OH!
Linked node problem 3 What set of statements turns this picture:
Linked node problem 3 What set of statements turns this picture:
LinkedIntList(int n) Write a constructor for LinkedIntList that accepts an int n parameter and makes a list of the number from 0 to n new LinkedIntList(3)
Chapter 13 Collections.
List Data Structure.
slides created by Marty Stepp and Ethan Apter
Building Java Programs
Building Java Programs
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.
Lecture 7: Linked List Basics reading: 16.2
Programming Abstractions
Programming II (CS300) Chapter 07: Linked Lists and Iterators
Building Java Programs
slides adapted from Marty Stepp and Hélène Martin
slides created by Marty Stepp and Hélène Martin
Building Java Programs
Data structures.
Building Java Programs
Lecture 8: Complex Linked List Code reading: 16.2 – 16.3
LinkedIntList(int n) Write a constructor for LinkedIntList that accepts an int n parameter and makes a list of the number from 0 to n new LinkedIntList(3)
More Data Structures (Part 1)
Building Java Programs
CSC 143 Java Linked Lists.
slides created by Marty Stepp
slides created by Alyssa Harding
Recursive Objects Singly Linked Lists.
slides adapted from Marty Stepp
Building Java Programs
Programming II (CS300) Chapter 07: Linked Lists
Queues: Implemented using Linked Lists
Lecture 7: Linked List Basics reading: 16.2
slides adapted from Marty Stepp
TCSS 143, Autumn 2004 Lecture Notes
Wednesday Questions How do I debug? We love to teach this at IPL/OH!
slides created by Marty Stepp
slides created by Marty Stepp
CMPT 225 Lecture 7 – Stack.
slides created by Marty Stepp
slides created by Marty Stepp and Hélène Martin
Presentation transcript:

changing a list There are only two ways to change a linked list: Change the value of front (modify the front of the list) Change the value of <node>.next (modify middle or end of list to point somewhere else) Implications: To add in the middle, need a reference to the previous node Front is often a special case

Common cases middle: "typical" case in the middle of an existing list back: special case at the back of an existing list front: special case at the front of an existing list empty: special case of an empty list

Other list features Add the following methods to the LinkedIntList: size isEmpty clear toString indexOf contains Add a size field to the list to return its size more efficiently. Add preconditions and exception tests to appropriate methods.

Smokey-Grey Litterbox-Feet Johnson