Chapter 9 Linked Lists.

Slides:



Advertisements
Similar presentations
Chapter 22 Implementing lists: linked implementations.
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.
Data Structures Using C++
CSE Lecture 12 – Linked Lists …
M180: Data Structures & Algorithms in Java
Data Structures: A Pseudocode Approach with C
1 Linked Lists Gordon College Prof. Brinton. 2 Linked List Basics Why use? 1.Efficient insertion or deletion into middle of list. (Arrays are not efficient.
Main Index Contents 11 Main Index Contents Abstract Model of a List Obj. Abstract Model of a List Obj. Insertion into a List Insertion into a List Linked.
C++ Programming: Program Design Including Data Structures, Fifth Edition Chapter 17: Linked Lists.
Chapter 3: Arrays, Linked Lists, and Recursion
Data Structures Using C++ 2E
Data Structures Using Java1 Chapter 4 Linked Lists.
Chapter 1 Object Oriented Programming. OOP revolves around the concept of an objects. Objects are created using the class definition. Programming techniques.
Lists Chapter 8. 2 Linked Lists As an ADT, a list is –finite sequence (possibly empty) of elements Operations commonly include: ConstructionAllocate &
Kovács Zita 2014/2015. II. félév DATA STRUCTURES AND ALGORITHMS 26 February 2015, Linked list.
Linked List by Chapter 5 Linked List by
Data Structures Using C++1 Chapter 5 Linked Lists.
1. Circular Linked List In a circular linked list, the last node contains a pointer to the first node of the list. In a circular linked list,
1 Data Organization Example 1: Heap storage management –Keep track of free chunks of memory Example 2: A simple text editor –Maintain a sequence of lines.
List Interface and Linked List Mrs. Furman March 25, 2010.
Chapter 5 Linked List by Before you learn Linked List 3 rd level of Data Structures Intermediate Level of Understanding for C++ Please.
Data Structures Doubly and Circular Lists Lecture 07: Linked Lists
ICOM 4035 – Data Structures Dr. Manuel Rodríguez Martínez Electrical and Computer Engineering Department.
Department of Computer Science 1 Some Practice Let’s practice for the final a little bit. OK?
Circular linked list A circular linked list is a linear linked list accept that last element points to the first element.
Chapter 17: Linked Lists. Objectives In this chapter, you will: – Learn about linked lists – Learn the basic properties of linked lists – Explore insertion.
C++ Programming: Program Design Including Data Structures, Fourth Edition Chapter 17: Linked Lists.
C++ Programming: From Problem Analysis to Program Design, Fourth Edition Chapter 18: Linked Lists.
Arrays, Link Lists, and Recursion Chapter 3. Sorting Arrays: Insertion Sort Insertion Sort: Insertion sort is an elementary sorting algorithm that sorts.
Data Structure and Algorithm: CIT231 Lecture 6: Linked Lists DeSiaMorewww.desiamore.com/ifm1.
LINKED LISTS.
Copyright © 2012 Pearson Education, Inc. Chapter 17: Linked Lists.
1 Data Organization Example 1: Heap storage management Maintain a sequence of free chunks of memory Find an appropriate chunk when allocation is requested.
Lists and the Collection Interface Chapter 4. Chapter 4: Lists and the Collection Interface2 Chapter Objectives To become familiar with the List interface.
Chapter 3 Lists, Stacks, Queues. Abstract Data Types A set of items – Just items, not data types, nothing related to programming code A set of operations.
Linked Lists Source: presentation based on notes written by R.Kay, A. Hill and C.Noble ● Lists in general ● Lists indexed using pointer arrays ● Singly.
1 Chapter 24 Implementing Lists, Stacks, Queues, and Priority Queues Jung Soo (Sue) Lim Cal State LA.
Chapter 16: Linked Lists.
Linked List ADT used to store information in a list
Lecture 6 of Computer Science II
C++ Programming:. Program Design Including
[Chapter 4; Chapter 6, pp ] CSC 143 Linked Lists (cont) [Chapter 4; Chapter 6, pp ]
Data Structure By Amee Trivedi.
Vectors 5/31/2018 9:25 AM Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia, and.
Lectures linked lists Chapter 6 of textbook
UNIT – I Linked Lists.
CMSC202 Computer Science II for Majors Lecture 12 – Linked Lists
Data structures and algorithms
Review Deleting an Element from a Linked List Deletion involves:
More Linking Up with Linked Lists
Linked Lists Linked Lists 1 Sequences Sequences 07/25/16 10:31
UNIT-3 LINKED LIST.
Sequences 8/2/ :16 AM Linked Lists Linked Lists.
A Doubly Linked List There’s the need to access a list in reverse order prev next data dnode header 1.
Linked List Sudeshna Sarkar.
Programmazione I a.a. 2017/2018.
Chapter 18: Linked Lists.
Sequences 11/27/2018 1:37 AM Singly Linked Lists Singly Linked Lists.
Linked Lists.
Doubly Linked Lists or Two-way Linked Lists
11-3 LINKED LISTS A linked list is a collection of data in which each element contains the location of the next element—that is, each element contains.
CS212D: Data Structures Week 5-6 Linked List.
Chapter 24 Implementing Lists, Stacks, Queues, and Priority Queues
Problem Understanding
Chapter 17: Linked Lists.
More on Linked List Yumei Huo Department of Computer Science
BY PROF. IRSHAD AHMAD LONE.
The List Container and Iterators
LINEAR DATA STRUCTURES
Problem Understanding
Presentation transcript:

Chapter 9 Linked Lists

Outline Abstract Model of a List Obj. Handling the Back of the List Insertion into a List Linked List (LL) nodes Node Composition Inserting at the Front of a LL Deleting from the Front of a LL Removing a Target Node Handling the Back of the List Designing a New LL Structure Inserting a Node at a Position Circular Doubly LL’s Updating a Doubly LL

Abstract Model of a List Object

Insertion Into a List by Shifting Vector Storage Elements

Linked List Nodes Each Node is like a piece of a chain Individual Piece Pop Chain To insert a new link, break the chain at the desired location and simply reconnect at both ends of the new piece.

Linked List Nodes Removal is like Insertion in reverse.

Node Composition An individual Node is composed of two parts, a Data field containing the data stored by the node, and a Pointer field that marks the address of the next Node in the list. Node Class: Page 1049

§- singly linked lists - Each node contains a value and a pointer to the next node in the list. - The list begins with a pointer to the first node of the list and terminates when a node has a NULL pointer. 8

§- Inserting/Deleting at the front of a singly linked list - Set the pointer in the new node to the previous value of front. - update front to point at the new node. 2) Erase - assign front the pointer value of the first node, and then delete the node. 9

Inserting at the Front of a Linked List

Deleting From the Front of a Linked List

§- Inserting/Erasing inside a singly linked list - Maintain a pointer to the current list node and a pointer to the previous node. - Change the pointer value in the previous node. 12

Removing a Target Node

Handling the Back of the List

§- Insert/Delete at the back of a singly linked list - Maintain a pointer to the last list node that has value NULL when the list is empty. - Assign a “back” pointer the address of the first node added to the list. - To add other nodes at the back: 1) allocate a new node 2) assign the pointer in node “back” to point to the new node 3) assign the pointer “back” the address of the new node. 15

Designing a New Linked List Structure

Singly LinkedList P1050: LinkedList.h

§- Doubly linked lists - provide the most flexible implementation for the sequential list. §- Its nodes have pointers to the next and the previous node, so the program can traverse a list in either the forward or backward direction. - Traverse a list by starting at the first node and follow the sequence of next nodes until you arrive back at the header. - To traverse a list in reverse order, start at the last node and follow the sequence of previous nodes until arriving back at the header. dnode Class 18

Inserting a Node at a Position

Deleting a Node at a Position

Circular Doubly Linked Lists A Watch Band provides a good Real Life analogue for this Data Structure

Circular Doubly Linked Lists Implemented on a Computer it might look something like this.

Updating a Doubly Linked List