Doubly linked lists Idea: same as singly linked list, but each node also points to the previous: Can optionally also have a pointer to the tail, so we.

Slides:



Advertisements
Similar presentations
Chapter 6 Structures By C. Shing ITEC Dept Radford University.
Advertisements

1 CSC 211 Data Structures Lecture 22 Dr. Iftikhar Azim Niaz 1.
CS 106 Introduction to Computer Science I 12 / 06 / 2006 Instructor: Michael Eckmann.
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.
Linked Lists CSC 172 SPRING 2004 LECTURE 6. ANNOUNCEMENTS Project 2 due Wed, Feb 18 th, 5PM, CSB Read Weiss Chapter 17 Department T shirts available $10.
Chapter 12 C Data Structures Acknowledgment The notes are adapted from those provided by Deitel & Associates, Inc. and Pearson Education Inc.
COMP 110 Introduction to Programming Mr. Joshua Stough.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 12 – Data Structures Outline 12.1Introduction.
1 Stack Data : a collection of homogeneous elements arranged in a sequence. Only the first element may be accessed Main Operations: Push : insert an element.
Algorithms and Data Structures Representing Sequences by Arrays and Linked Lists.
Chapter 17 Linked List.
Chapter 12 Data Structure Associate Prof. Yuh-Shyan Chen Dept. of Computer Science and Information Engineering National Chung-Cheng University.
Trees, Binary Search Trees, Recursion, Project 2 Bryce Boe 2013/08/01 CS24, Summer 2013 C.
Reference: Vinu V Das, Principles of Data Structures using C and C++
ECE 103 Engineering Programming Chapter 61 Abstract Data Types Herbert G. Mayer, PSU CS Status 6/4/2014 Initial content copied verbatim from ECE 103 material.
Last meeting..Doubly Linked List  InsertToFront  InsertToEnd  Search  DeleteNode.
1 Chapter 7 Stacks and Queues. 2 Stack ADT Recall that ADT is abstract data type, a set of data and a set of operations that act upon the data. In a stack,
Data Structures (part 2). Stacks An Everyday Example Your boss keeps bringing you important items to deal with and keeps saying: “Put that last ‘rush’
Cousin of the Stack.  An abstract data type (container class) in which items are entered at one end and removed from the other end  First In First.
1 Chapter 17 – Data Structures Outline Introduction Self-Referential Classes Dynamic Memory Allocation Linked Lists Stacks Queues Trees.
Kovács Zita 2014/2015. II. félév DATA STRUCTURES AND ALGORITHMS 26 February 2015, Linked list.
Chapter 16 – Data Structures and Recursion. Data Structures u Built-in –Array –struct u User developed –linked list –stack –queue –tree Lesson 16.1.
Data Structures Chapter 6. Data Structure A data structure is a representation of data and the operations allowed on that data. Examples: 1.Array 2.Record.
Data Structures for Midterm 2. C++ Data Structure Runtimes.
Lecture 20 Stacks and Queues. Stacks, Queues and Priority Queues Stacks – first-in-last-out structure – used for function evaluation (run-time stack)
Week 4 - Friday.  What did we talk about last time?  Continued doubly linked list implementation  Linked lists with iterators.
Data Structures David Kauchak cs302 Spring Data Structures What is a data structure? Way of storing data that facilitates particular operations.
Stacks and Queues CMSC 201. Stacks and Queues Sometimes, when we use a data-structure in a very specific way, we have a special name for it. This is to.
CS32 Discussion Section 1B Week 3 TA: Hao Yu (Cody)
© Oxford University Press All rights reserved. Data Structures Using C, 2e Reema Thareja.
CPS120: Introduction to Computer Science Nell Dale John Lewis Abstract Data Types.
CPSC 252 Linked Lists III Page 1 Variations on Singly Linked Lists Inserting or deleting at the front of a list is different from at any other point in.
One implementation of the LIST ADT Insert new node before current and new node becomes current (assume new node created) node newNode = new node; head.
1 Chapter 24 Implementing Lists, Stacks, Queues, and Priority Queues Jung Soo (Sue) Lim Cal State LA.
Cpt S 122 – Data Structures Abstract Data Types
Elementary data structures
Week 4 - Monday CS221.
Understanding Algorithms and Data Structures
Data Structure By Amee Trivedi.
G64ADS Advanced Data Structures
Set Collection A Bag is a general collection class that implements the Collection interface. A Set is a collection that resembles a Bag with the provision.
Chapter 12 – Data Structures
Week 4 - Friday CS221.
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.
Animationer ur Weiss kap. 16 Figurerna 16.20, 16.25
Linked List Stacks, Linked List Queues, Dequeues
Chapter 15 Lists Objectives
UNIT-3 LINKED LIST.
Sequences 8/1/2018 4:38 AM Linked Lists Linked Lists.
Stacks and Queues CMSC 202.
Stacks and Queues.
Stack and Queue APURBO DATTA.
Stack and Queue Author : Srinadh Gunnam.
Java collections library
Data Structures and Algorithms IT12112
Basic Data Types Queues
CMSC 341 Lecture 5 Stacks, Queues
Stacks, Queues, and Deques
Lecture 21 Stacks and Queues Richard Gesick.
Linear Data Structures Chapter 3
אחסון (אירגון) מידע DATA DATA DATA Link Link Link … …
ITEC 2620M Introduction to Data Structures
Node Applications in Abstract Data Types
Queues A first-in, first-out or FIFO data structure.
Chapter 24 Implementing Lists, Stacks, Queues, and Priority Queues
Binary Tree Traversals
Mutable Data (define mylist (list 1 2 3)) (bind ((new (list 4)))
LINKED LISTS.
Breadth First Search - A B C D E F G H I front FIFO Queue.
CS210- Lecture 6 Jun 13, 2005 Announcements
Presentation transcript:

Doubly linked lists Idea: same as singly linked list, but each node also points to the previous: Can optionally also have a pointer to the tail, so we can start scanning from the end, and make appending easier Also helps with binary search

Inserting into a DLL Find node before the new one, nextNode Set newNode.prev = nextNode.prev Set newNode.prev.next = newNode Set newNode.next = nextNode Set nextNode.prev = newNode

Queues Main idea: similar to a stack, but use “First in, first out” methodology ”Push” and “Pop” now become “enqueue” and “dequeue” Primary stipulation: dequeue returns the least-recently enqueued item