Doubly Linked Lists 6/3/2018 Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia,

Slides:



Advertisements
Similar presentations
Lists1 © 2010 Goodrich, Tamassia. Position ADT The Position ADT models the notion of place within a data structure where a single object is stored It.
Advertisements

Iterators and Sequences1 © 2010 Goodrich, Tamassia.
© 2004 Goodrich, Tamassia Vectors1. © 2004 Goodrich, Tamassia Vectors2 The Vector ADT (“Vector” = “Array List” in §6.1) The Vector ADT extends the notion.
© 2004 Goodrich, Tamassia Sequences and Iterators1.
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.
© 2004 Goodrich, Tamassia Lists1. © 2004 Goodrich, Tamassia Lists2 Position ADT (§ 5.2.2) The Position ADT models the notion of place within a data structure.
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.
© 2004 Goodrich, Tamassia Vectors1 Lecture 03 Vectors, Lists and Sequences Topics Vectors Lists Sequences.
Doubly Linked Lists1 © 2014 Goodrich, Tamassia, Goldwasser Presentation for use with the textbook Data Structures and Algorithms in Java, 6 th edition,
© 2004 Goodrich, Tamassia Linked Lists1. © 2004 Goodrich, Tamassia Linked Lists2 Singly Linked List (§ 4.4.1) A singly linked list is a concrete data.
© 2004 Goodrich, Tamassia Sequences and Iterators1.
Data Structures Using Java1 Chapter 4 Linked Lists.
CS 221 Analysis of Algorithms Data Structures Vectors, Lists.
© 2014 Goodrich, Tamassia, Goldwasser Singly Linked Lists1 Presentation for use with the textbook Data Structures and Algorithms in Java, 6 th edition,
Arrays1 © 2014 Goodrich, Tamassia, Goldwasser Presentation for use with the textbook Data Structures and Algorithms in Java, 6 th edition, by M. T. Goodrich,
© 2004 Goodrich, Tamassia Lists1. © 2004 Goodrich, Tamassia Lists2 Position ADT (§ 5.2.2) The Position ADT models the notion of place within a data structure.
Data Structures Doubly and Circular Lists Lecture 07: Linked Lists
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.
Lists1 © 2010 Goodrich, Tamassia. Position ADT  The Position ADT models the notion of place within a data structure where a single object is stored 
CHAPTER 10.1 BINARY SEARCH TREES    1 ACKNOWLEDGEMENT: THESE SLIDES ARE ADAPTED FROM SLIDES PROVIDED WITH DATA STRUCTURES AND ALGORITHMS.
Arrays, Link Lists, and Recursion Chapter 3. Sorting Arrays: Insertion Sort Insertion Sort: Insertion sort is an elementary sorting algorithm that sorts.
CH 1-4 : INTRODUCTION ACKNOWLEDGEMENT: THE SLIDES ARE PREPARED FROM SLIDES PROVIDED WITH DATA STRUCTURES AND ALGORITHMS IN C++, GOODRICH, TAMASSIA AND.
© 2004 Goodrich, Tamassia Queues. © 2004 Goodrich, Tamassia Stacks2 The Queue ADT The Queue ADT stores arbitrary objects Insertions and deletions follow.
Adaptable Priority Queues1 3 a 5 g 4 e © 2014 Goodrich, Tamassia, Goldwasser Presentation for use with the textbook Data Structures and Algorithms in Java,
Queues1 © 2014 Goodrich, Tamassia, Goldwasser Presentation for use with the textbook Data Structures and Algorithms in Java, 6 th edition, by M. T. Goodrich,
Merge Sort 1/12/2018 9:44 AM Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia,
Sorted Maps © 2014 Goodrich, Tamassia, Goldwasser Skip Lists.
Sorting Lower Bound 4/25/2018 8:49 PM
Lecture 6 of Computer Science II
Lists and Iterators 5/3/2018 Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia,
Skip Lists 5/10/2018 Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia, and M.
Iterators and Sequences
Data Structure By Amee Trivedi.
Binary Search Trees < > =
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.
Ch7. List and Iterator ADTs
Binary Search Trees < > =
Sequences 6/3/2018 9:11 AM Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia,
Linked List Stacks, Linked List Queues, Dequeues
AVL Trees 6/25/2018 Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia, and M.
Linked Lists Linked Lists 1 Sequences Sequences 07/25/16 10:31
B-Trees 7/5/2018 4:26 AM Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia, and.
EEL 4854 IT Data Structures Linked Lists
Heaps 8/2/2018 Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia, and M. H. Goldwasser,
Tries 9/14/ :13 AM Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia, and.
Skip Lists S3 + - S2 + - S1 + - S0 + -
LINKED LISTS CSCD Linked Lists.
AVL Trees 4/29/15 Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia, and M. H.
Ch7. List and Iterator ADTs
Lists and Iterators 3/9/15 Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia,
Sequences 11/22/2018 3:25 AM Doubly-Linked Lists Doubly-Linked Lists.
" A list is only as strong as its weakest link. " - Donald Knuth
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.
Queues 3/9/15 Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia, and M. H. Goldwasser,
CS2013 Lecture 4 John Hurley Cal State LA.
Doubly Linked Lists Lecture 21 Tue, Mar 21, 2006.
Copyright © Aiman Hanna All rights reserved
Problem Understanding
Recall What is a Data Structure Very Fundamental Data Structures
Binary Search Trees < > =
Linked Lists & Iterators
Binary Search Trees < > =
Linked Lists.
Linked Lists.
Chapter 9 Linked Lists.
Jyh-Shing Roger Jang (張智星) CSIE Dept, National Taiwan University
Problem Understanding
Presentation transcript:

Doubly Linked Lists 6/3/2018 Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia, and M. H. Goldwasser, Wiley, 2014 Doubly Linked Lists © 2014 Goodrich, Tamassia, Goldwasser Doubly Linked Lists

Doubly Linked List A doubly linked list can be traversed forward and backward Nodes store: element link to the previous node link to the next node Special trailer and header nodes prev next element node trailer header nodes/positions elements © 2014 Goodrich, Tamassia, Goldwasser Doubly Linked Lists

Header and trailer Make implementation easier Every insertion/deletion is between two nodes Can be implemented without them Save space Need to consider special cases at the beginning and at the end © 2014 Goodrich, Tamassia, Goldwasser Doubly Linked Lists

Insertion p A B C p q A B C What are the instructions? X p q A B X C Insert a new node, q, between p and its successor. p A B C p q A B C What are the instructions? X p q A B X C © 2014 Goodrich, Tamassia, Goldwasser Doubly Linked Lists

Deletion A B C D p A B C p What are the instructions? D A B C Remove a node, p, from a doubly linked list. A B C D p A B C p What are the instructions? D A B C © 2014 Goodrich, Tamassia, Goldwasser Doubly Linked Lists

Doubly-Linked List in Java © 2014 Goodrich, Tamassia, Goldwasser Doubly Linked Lists

Doubly-Linked List in Java, 2 Lines 26-27: Why are the parameters different? Why do we need line 28? © 2014 Goodrich, Tamassia, Goldwasser Doubly Linked Lists

Doubly-Linked List in Java, 3 © 2014 Goodrich, Tamassia, Goldwasser Doubly Linked Lists

Doubly-Linked List in Java, 4 Do we want to put lines 69 and 70 before line 68? Why? © 2014 Goodrich, Tamassia, Goldwasser Doubly Linked Lists

Doubly-Linked List in Java, 4 © 2014 Goodrich, Tamassia, Goldwasser Doubly Linked Lists

== vs equals() Person person1, person2 What is the difference between person1.equals(person2) © 2014 Goodrich, Tamassia, Goldwasser Doubly Linked Lists