doubly linked lists1 © 2014 goodrich, tamassia, goldwasser presentation for use with the textbook...

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

Upload: augustine-tyler

Post on 21-Dec-2015

228 views

Category:

Documents


4 download

TRANSCRIPT

Page 1: Doubly Linked Lists1 © 2014 Goodrich, Tamassia, Goldwasser Presentation for use with the textbook Data Structures and Algorithms in Java, 6 th edition,

Doubly Linked Lists 1

Doubly Linked Lists

© 2014 Goodrich, Tamassia, Goldwasser

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

Page 2: Doubly Linked Lists1 © 2014 Goodrich, Tamassia, Goldwasser Presentation for use with the textbook Data Structures and Algorithms in Java, 6 th edition,

Doubly Linked Lists 2

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

trailerheader nodes/positions

elements

node

© 2014 Goodrich, Tamassia, Goldwasser

Page 3: Doubly Linked Lists1 © 2014 Goodrich, Tamassia, Goldwasser Presentation for use with the textbook Data Structures and Algorithms in Java, 6 th edition,

Doubly Linked Lists 3

Insertion Insert a new node, q, between p and its successor.

A B X C

A B C

p

A B C

p

X

q

p q

© 2014 Goodrich, Tamassia, Goldwasser

Page 4: Doubly Linked Lists1 © 2014 Goodrich, Tamassia, Goldwasser Presentation for use with the textbook Data Structures and Algorithms in Java, 6 th edition,

Doubly Linked Lists 4

Deletion Remove a node, p, from a doubly linked list.

A B C D

p

A B C

D

p

A B C© 2014 Goodrich, Tamassia, Goldwasser

Page 5: Doubly Linked Lists1 © 2014 Goodrich, Tamassia, Goldwasser Presentation for use with the textbook Data Structures and Algorithms in Java, 6 th edition,

Doubly-Linked List in Java

© 2014 Goodrich, Tamassia, Goldwasser Doubly Linked Lists 5

Page 6: Doubly Linked Lists1 © 2014 Goodrich, Tamassia, Goldwasser Presentation for use with the textbook Data Structures and Algorithms in Java, 6 th edition,

Doubly-Linked List in Java, 2

© 2014 Goodrich, Tamassia, Goldwasser Doubly Linked Lists 6

Page 7: Doubly Linked Lists1 © 2014 Goodrich, Tamassia, Goldwasser Presentation for use with the textbook Data Structures and Algorithms in Java, 6 th edition,

Doubly-Linked List in Java, 3

© 2014 Goodrich, Tamassia, Goldwasser Doubly Linked Lists 7

Page 8: Doubly Linked Lists1 © 2014 Goodrich, Tamassia, Goldwasser Presentation for use with the textbook Data Structures and Algorithms in Java, 6 th edition,

Doubly-Linked List in Java, 4

© 2014 Goodrich, Tamassia, Goldwasser Doubly Linked Lists 8