Linked List ADT used to store information in a list

Slides:



Advertisements
Similar presentations
Pointers.
Advertisements

Linked Lists.
Linked Lists Linked Lists Representation Traversing a Linked List
Data Structures Using C++
CHP-5 LinkedList.
Chapter 17 Linked List Saurav Karmakar Spring 2007.
Review Learn about linked lists
Data Structures: A Pseudocode Approach with C
1 Chapter 24 Lists Stacks and Queues. 2 Objectives F To design list with interface and abstract class (§24.2). F To design and implement a dynamic list.
Data Structures & Algorithms
1 Problem Solving Abstraction Oftentimes, different real-world problems can be modeled using the same underlying idea Examples: Runtime storage, Undo operation.
C++ Programming: Program Design Including Data Structures, Third Edition Chapter 17: Linked Lists.
C++ Programming: Program Design Including Data Structures, Third Edition Chapter 17: Linked Lists.
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.
Chapter 4 Linked Lists. © 2005 Pearson Addison-Wesley. All rights reserved4-2 Preliminaries Options for implementing an ADT List –Array has a fixed size.
C++ Programming: Program Design Including Data Structures, Fifth Edition Chapter 17: Linked Lists.
2 Preliminaries Options for implementing an ADT List Array has a fixed size Data must be shifted during insertions and deletions Linked list is able to.
Implementation of Linked List For more notes and topics visit: eITnotes.com.
CSE 131 Computer Science 1 Module 9: Linked Lists Using references to link objects Basic operations on linked lists Implementing a linked list of integers.
Data Structures Using Java1 Chapter 4 Linked Lists.
Department of Computer Science Data Structures Using C++ 2E Chapter 5 Linked Lists.
Lists Chapter 8. 2 Linked Lists As an ADT, a list is –finite sequence (possibly empty) of elements Operations commonly include: ConstructionAllocate &
Linked Lists © John Urrutia 2013, All Rights Reserved1.
Kovács Zita 2014/2015. II. félév DATA STRUCTURES AND ALGORITHMS 26 February 2015, Linked list.
Linked List Chapter Data Abstraction separates the logical properties of a data type from its implementation LOGICAL PROPERTIES – What are the.
Subject Name : Data Structure Using C Title : Linked Lists
Linked List Containers. Linked Lists List consists of multiple listnodes List consists of multiple listnodes Each listnode consists of Each listnode consists.
Data Structures Using C++1 Chapter 5 Linked Lists.
CS2006- Data Structures I Chapter 5 Linked Lists III.
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,
Data Structures Doubly and Circular Lists Lecture 07: Linked Lists
2/21/20161 List Operations Advanced Programming Ananda Gunawardena.
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.
Linked list: a list of items (nodes), in which the order of the nodes is determined by the address, called the link, stored in each node C++ Programming:
1 Linked List. Outline Introduction Insertion Description Deletion Description Basic Node Implementation Conclusion.
Data Structure & Algorithms
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.
 2015, Marcus Biel, Linked List Data Structure Marcus Biel, Software Craftsman
UNIT-II Topics to be covered Singly linked list Circular linked list
LINKED LISTS.
Copyright © 2012 Pearson Education, Inc. Chapter 17: Linked Lists.
1 Linked List. List vs Arrays Two built-in data structures that can be used to organize data, or to create other data structures: Lists Arrays.
Chapter 16: Linked Lists.
Unit – I Lists.
C++ Programming:. Program Design Including
Data Structure By Amee Trivedi.
Linked List :: Basic Concepts
Lectures linked lists Chapter 6 of textbook
Linked Lists Chapter 6 Section 6.4 – 6.6
Data structures and algorithms
Review Deleting an Element from a Linked List Deletion involves:
More Linking Up with Linked Lists
Chapter 4 Linked Lists.
LINKED LISTS CSCD Linked Lists.
Arrays and 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.
CS2013 Lecture 4 John Hurley Cal State LA.
Problem Understanding
Linked List and Selection Sort
Chapter 17: Linked Lists.
Introduction to Data Structure
By Yogesh Neopaney Assistant Professor Department of Computer Science
Linked Lists.
BY PROF. IRSHAD AHMAD LONE.
Chapter 9 Linked Lists.
LINEAR DATA STRUCTURES
CMPT 225 Lecture 5 – linked list.
Presentation transcript:

Linked List ADT used to store information in a list Consists of a series of “linked” containers, called “nodes”, that hold the stored data Each node contains: Storage for one data element A pointer to the next element in the list The linked list maintains a pointer to the first element The pointer stored in the last node is set to NULL

Linked List Node Node Node Node Data Data Data Data head Node* Node* NULL

Advantages/Disadvantages Can add additional items to the list without affecting existing items Can insert items into arbitrary locations Allows for maintaining a sorted list as elements are added No wasted memory – only allocate what’s needed Disadvantage Access is not random Locating an item requires a sequential search Memory overhead (need to store pointers) Storage is not localized

Source: www.slideshare.net

Iterators A special class that is used to sequentially search a linked list Needed to maintain “encapsulation” Individual nodes (and pointers) should remain hidden from a user Usually declared a “friend” of the linked list Since it needs to keep track of the nodes in the list A compromise to normal OOP practices

Iterator operation Iterator maintains a pointer to a “current “ list node Each sequential call to an update/next method moves the pointer to the next list node Iterator starts at the head node A method is provided to reset the pointer to the head so the iterator can be reused A method is provided to access the stored data in the current node Iterators shield the user from the details of Node properties (and existence) Pointer manipulation Multiple iterators can be created for a given list

More complex Linked Lists Linked lists can be made circular “last” node points back to “first” Doubly linked Two pointers per node Allows both forwards and backwards traversal