Data Structures(I) Circular Linked Lists Circular linked list A list in which every node has a successor; the last element is succeeded by the first element.

Slides:



Advertisements
Similar presentations
Chapter 22 Implementing lists: linked implementations.
Advertisements

Linked Lists CS-212 Dick Steflik. Linked Lists A sequential collection of information Can be unordered; i.e. in no specific order Can be ordered; may.
Stacks, Queues, and Linked Lists
Linked Lists.
JAVA & Linked List Implementation
Linear Lists – Linked List Representation
Chapter 3 – Lists A list is just what the name implies, a finite, ordered sequence of items. Order indicates each item has a position. A list of size 0.
Computer Science and Software Engineering University of Wisconsin - Platteville 5. LinkedList Yan Shi CS/SE 2630 Lecture Notes.
Queues A waiting line that grows by adding elements to its end and shrinks by taking elements from its front Line at the grocery store Cars in traffic.
Chapter 17 Linked List Saurav Karmakar Spring 2007.
M180: Data Structures & Algorithms in Java
Lists + CS3240, L. Grewe 1. 2 Goals Use the C++ template mechanism fr defining generic data types Implement a circular linked list Implement a linked.
Review Learn about linked lists
Linked Lists. Example We would like to keep a list of inventory records – but only as many as we need An array is a fixed size Instead – use a linked.
Data Structures Simple data type –int, char, long Reference data type –Integer, String, Composite data type == Data Structure –Collection of elements.
Data Structures: A Pseudocode Approach with C
Linked list More terminology Singly-linked lists Doubly-linked lists DLLs compared to SLLs Circular Lists.
Linked Lists Compiled by Dr. Mohammad Alhawarat CHAPTER 04.
Linked Lists in C and C++ By Ravi Prakash PGT(CS).
CS Data Structures Chapter 8 Lists Mehmet H Gunes
Data Structures & Algorithms
Chapter 4 ADT Sorted List.
Comparison summary Array based (dynamic) Keeps place for up to 4N elements Each element takes 1 memory places Fast accession time Slow removals and insertion.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Sixth Edition Chapter 17: Linked Lists.
Linked Lists. Example We would like to keep a list of inventory records – but only as many as we need An array is a fixed size Instead – use a linked.
CS102 – Data Structures Lists, Stacks, Queues, Trees, Hash Collections Framework David Davenport Spring 2002.
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.
Data Structures Topic #3. Today’s Agenda Ordered List ADTs –What are they –Discuss two different interpretations of an “ordered list” –Are manipulated.
Starting Out with C++: Early Objects 5/e © 2006 Pearson Education. All Rights Reserved Starting Out with C++: Early Objects 5 th Edition Chapter 17 Linked.
Summary of lectures (1 to 11)
1 Chapter 6 Lists Plus. ADT Sorted List Operations Transformers n MakeEmpty n InsertItem n DeleteItem Observers n IsFull n LengthIs n RetrieveItem Iterators.
© 2004 Goodrich, Tamassia Linked Lists1. © 2004 Goodrich, Tamassia Linked Lists2 Singly Linked List (§ 4.4.1) A singly linked list is a concrete data.
Chapter 3: Arrays, Linked Lists, and Recursion
Doubly Linked Lists Deleting from the end of the list – Have to traverse the entire list to stop right in front of tail to delete it, so O(n) – With head.
1 Nell Dale Chapter 6 Lists Plus Slides by Sylvia Sorkin, Community College of Baltimore County - Essex Campus C++ Plus Data Structures.
Chapter 7 More Lists. Chapter 7: More Lists 7.1 – Circular Linked Lists 7.2 – Doubly Linked Lists 7.3 – Linked Lists with Headers and Trailers 7.4 – A.
Data Structures Week 5 Further Data Structures The story so far  We understand the notion of an abstract data type.  Saw some fundamental operations.
Adapted from instructor resources Nyhoff, ADTs, Data Structures and Problem Solving with C++, Second Edition, © 2005 Pearson Education, Inc. All rights.
4-1 Topic 6 Linked Data Structures. 4-2 Objectives Describe linked structures Compare linked structures to array- based structures Explore the techniques.
Stacks And Queues Chapter 18.
1 Linked-list, stack and queue. 2 Outline Abstract Data Type (ADT)‏ Linked list Stack Queue.
Starting Out with C++ Early Objects Seventh Edition by Tony Gaddis, Judy Walters, and Godfrey Muganda Chapter 17: Linked Lists.
1 Linked Structures, LinkedSet References as Links Linear Linked Lists and Non-linear Structures Managing Linked Lists Data Encapsulation Separate from.
1 Linked Lists (Lec 6). 2  Introduction  Singly Linked Lists  Circularly Linked Lists  Doubly Linked Lists  Multiply Linked Lists  Applications.
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.
Chapter 6 Lists Plus. What is a Class Template? A class template allows the compiler to generate multiple versions of a class type by using type parameters.
Linear Data Structures
Queue, Deque, and Priority Queue Implementations Chapter 23.
1 What is a Circular Linked List? l A circular linked list is a list in which every node has a successor; the “last” element is succeeded by the “first”
Department of Computer Science 1 Some Practice Let’s practice for the final a little bit. OK?
CS162 - Topic #7 Lecture: Dynamic Data Structures –Review of pointers and the new operator –Introduction to Linked Lists –Begin walking thru examples of.
Data Structure & Algorithms
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Seventh Edition by Tony Gaddis, Judy.
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.
Sorted Linked List Same objective as a linked list, but it should be sorted Sorting can be custom according to the type of nodes Offers speedups over non-sorted.
Lecture - 6 On Data Structures
COP3530- Data Structures Advanced Lists
Stacks and Queues.
LINKED LISTS CSCD Linked Lists.
Chapter 4 Link Based Implementations
Arrays and Linked Lists
Queue and Priority Queue Implementations
Further Data Structures
Linked Lists.
Doubly Linked Lists or Two-way Linked Lists
Lecture 16 Section 6.2 Thu, Mar 1, 2007
Yan Shi CS/SE 2630 Lecture Notes
Chapter 9 Linked Lists.
Presentation transcript:

Data Structures(I) Circular Linked Lists Circular linked list A list in which every node has a successor; the last element is succeeded by the first element

Data Structures(I) A more efficient approach Adding and removing elements at the front of a list might be a common operation for some applications. Our linked list approach supports these operations very efficiently The previous linked list approach does not (we need to access the last element also). We can fix this problem by letting our list reference point to the last element in the list rather than the first; now we have easy access to both the first and the last elements in the list.

Data Structures(I) The remove method

Data Structures(I) Adding a node

Data Structures(I) Doubly Linked Lists Doubly linked list A linked list in which each node is linked to both its successor and its predecessor

Data Structures(I) The add operation

Data Structures(I) The remove operation

Data Structures(I) Linked Lists with Headers and Trailers Header node A placeholder node at the beginning of a list; used to simplify list processing Trailer node A placeholder node at the end of a list; used to simplify list processing

Data Structures(I) A Linked List as an Array of Nodes

Data Structures(I) Why Use an Array? Sometimes managing the free space ourselves gives us greater flexibility There are programming languages that do not support dynamic allocation or reference types There are times when dynamic allocation of each node, one at a time, is too costly in terms of time

Data Structures(I) Roundedness A desire for static allocation is one of the primary motivations for the array-based linked approach We drop our assumption that our lists are of unlimited size in this section - our lists will not grow as needed. Applications should not add elements to a full list. Our list will export an isFull operation, in addition to all the other standard list operations

Data Structures(I) A sorted list

Data Structures(I) A linked list and free space

Data Structures(I) More than one list

Data Structures(I)