Linked List Stacks, Linked List Queues, Dequeues

Slides:



Advertisements
Similar presentations
Chapter 3 Lists Dr Zeinab Eid.
Advertisements

CSCE 3110 Data Structures & Algorithm Analysis
Queues and Linked Lists
1111 Abstract Data Types Cpt S 223. School of EECS, WSU.
Doubly Linked List This problem can be easily solved by using the double linked list. - Ed. 2 and 3.: Chapter 4 - Ed. 4: Chapter 3.
Data Structure HKOI training /4/2010 So Pak Yeung.
6/7/2014 8:24 AMSequences1 Lists and Sequences. 6/7/2014 8:24 AMSequences2 Outline and Reading Singly linked list Position ADT and List ADT (§5.2.1) Doubly.
1 Array-based Implementation An array Q of maximum size N Need to keep track the front and rear of the queue: f: index of the front object r: index immediately.
3 May Linked Lists CSE 2011 Winter Linked Lists2 Singly Linked Lists (3.2) A singly linked list is a concrete data structure consisting of.
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.
Queue & List Data Structures & Algorithm Abstract Data Types (ADTs) ADT is a mathematically specified entity that defines a set of its instances,
Doubly Linked Lists. One powerful variation of a linked list is the doubly linked list. The doubly linked list structure is one in which each node has.
Queues 4/14/2017 5:24 PM 5.2 Queues Queues Dr Zeinab Eid.
1 Queues (5.2) CSE 2011 Winter May Announcements York Programming Contest Link also available from.
Queues. What is a queue? First-in first-out data structure (FIFO) New objects are placed at rear Removal restricted to front Examples?
Queues. What is a queue? First-in first-out data structure (FIFO) New objects are placed at rear Removal restricted to front Examples?
CS 206 Introduction to Computer Science II 09 / 17 / 2008 Instructor: Michael Eckmann.
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.
Fall 2007CS 2251 Queues Chapter 6. Fall 2007CS 2252 Chapter Objectives To learn how to represent a waiting line (queue) and how to use the methods in.
CSC 212 Stacks & Queues. Announcement Daily quizzes accepted electronically only  Submit via one or other Dropbox  Cannot force you to compile & test.
© 2004 Goodrich, Tamassia Linked Lists1. © 2004 Goodrich, Tamassia Linked Lists2 Singly Linked List (§ 4.4.1) A singly linked list is a concrete data.
CS 206 Introduction to Computer Science II 09 / 19 / 2008 Instructor: Michael Eckmann.
October 18, Algorithms and Data Structures Lecture V Simonas Šaltenis Nykredit Center for Database Research Aalborg University
October 18, Algorithms and Data Structures Lecture V Simonas Šaltenis Nykredit Center for Database Research Aalborg University
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 Lecture 14: Queues Lecturer: Santokh Singh CompSci 105 SS 2005 Principles of Computer Science.
1. Last Lecture Stacks and Queues implemented with a Linked List Doubly Linked Lists 2 Today.
Introduction Dynamic Data Structures Grow and shrink at execution time Linked lists are dynamic structures where data items are “linked up in a chain”
Lab - 11 Keerthi Nelaturu. Ordered Structure Using Doubly linked list All elements in the list are arranged in an order Implement the Ordered Structure.
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.
© 2004 Goodrich, Tamassia Queues. © 2004 Goodrich, Tamassia Stacks2 The Queue ADT The Queue ADT stores arbitrary objects Insertions and deletions follow.
Linked List, Stacks Queues
Lecture 6 of Computer Science II
Elementary Data Structures
Cpt S 122 – Data Structures Abstract Data Types
Double-Ended Queues Chapter 5.
Program based on queue & their operations for an application
Queues Rem Collier Room A1.02
Linked Lists Linked Lists 1 Sequences Sequences 07/25/16 10:31
Doubly Linked List Review - We are writing this code
CSCE 3110 Data Structures & Algorithm Analysis
Sequences 8/1/2018 4:38 AM Linked Lists Linked Lists.
Sequences 8/2/ :13 AM Linked Lists Linked Lists.
Sequences 8/2/ :16 AM Linked Lists Linked Lists.
Algorithm for deleting a node from a singly linked list
EEL 4854 IT Data Structures Linked Lists
Lists and Sequences 9/21/2018 7:21 PM Sequences Sequences
LINKED LISTS CSCD Linked Lists.
Topic 16 Queues "FISH queue: n.
Topic 16 Queues Adapted from Mike Scott’s materials.
Sequences and Iterators
Circularly Linked Lists
Linked Lists: Implementation of Queue & Deque
Topic 16 Queues "FISH queue: n.
Sequences 12/8/2018 3:02 AM Linked Lists Linked Lists.
Doubly Linked Lists or Two-way Linked Lists
Lists and Sequences 12/8/2018 2:26 PM Sequences Sequences
CS212D: Data Structures Week 5-6 Linked List.
Doubly Linked Lists Lecture 21 Tue, Mar 21, 2006.
Problem Understanding
LINKED LISTS.
The List ADT Definition A list is a collection of objects, called nodes, connected in a chain by links. There may or may not be an ordering relationship.
Header and Trailer Sentinels
Using a Queue Chapter 8 introduces the queue data type.
Using a Queue Chapter 8 introduces the queue data type.
CS210- Lecture 6 Jun 13, 2005 Announcements
CS210- Lecture 7 Jun 14, 2005 Agenda Practice Session Vector
Stacks and Linked Lists
Queue, Deque, and Priority Queue Implementations
Presentation transcript:

Linked List Stacks, Linked List Queues, Dequeues

IMPLEMENTING A STACK WITH SINGLY LINKED LISTS Introduction Head Tail Lock at the code on the notes page  Page 2

IMPLEMENTING A QUEUE WITH SINGLY LINKED LISTS Head Tail The head of the list is the front of the queue. The tail of the list is the rear of the queue  Page 3

IMPLEMENTING A QUEUE WITH SINGLY LINKED LISTS  Page 4

DOUBLE ENDED QUEUES  Page 5

DOUBLE ENDED QUEUES  Page 6

Implementing Dequeues with Doubly Linked Lists  Page 7

Implementing Dequeues with Doubly Linked Lists Double Linked List Node Interface  Page 8

Implementing Dequeues with Doubly Linked Lists When implementing a doubly linked lists, we add two special nodes to the ends of the lists: the header and trailer nodes. The header node goes before the first list element. It has a valid next link but a null prev link. The trailer node goes after the last element. It has a valid prev reference but a null next reference. The header and trailer nodes are sentinel or “dummy” nodes because they do not store elements. • Here’s a diagram of our doubly linked list:  Page 9

Implementing Dequeues with Doubly Linked Lists Here’s a visualization of the code for removeLast().  Page 10

Implementing Dequeues with Doubly Linked Lists Size isEmpty First Last insertFirst insertLast RemoveFirst RemoveLast  Page 11

DOUBLE ENDED QUEUES  Page 12