1/ 124 COP 3503 FALL 2012 SHAYAN JAVED LECTURE 18 Programming Fundamentals using Java 1.

Slides:



Advertisements
Similar presentations
Chapter 25 Lists, Stacks, Queues, and Priority Queues
Advertisements

Stacks, Queues, and Linked Lists
Chapter 24 Lists, Stacks, and Queues
Stack & Queues COP 3502.
Stacks & Their Applications COP Stacks  A stack is a data structure that stores information arranged like a stack.  We have seen stacks before.
Stacks, Queues, and Deques. 2 A stack is a last in, first out (LIFO) data structure Items are removed from a stack in the reverse order from the way they.
CS Data Structures II Review COSC 2006 April 14, 2017
Abstract Data Types (ADT) Collection –An object that can hold a list of other objects Homogeneous Collection –Contains elements all of the same type –Example:
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.
Tirgul 3 Subjects of this Tirgul: Linked Lists Doubly-Linked Lists Sparse Matrices Stack Queue.
E.G.M. Petrakisstacks, queues1 Stacks  Stack: restricted variant of list  elements may by inserted or deleted from only one end : LIFO lists  top: the.
Unit 11 1 Unit 11: Data Structures H We explore some simple techniques for organizing and managing information H This unit focuses on: Abstract Data Types.
CS102 – Data Structures Lists, Stacks, Queues, Trees, Hash Collections Framework David Davenport Spring 2002.
1 Data Structures  We can now explore some advanced techniques for organizing and managing information  Chapter 12 of the book focuses on: dynamic structures.
Chapter 12 C Data Structures Acknowledgment The notes are adapted from those provided by Deitel & Associates, Inc. and Pearson Education Inc.
Lecture 6: Linked Lists Linked lists Insert Delete Lookup Doubly-linked lists.
Stack: Linked List Implementation Push and pop at the head of the list New nodes should be inserted at the front of the list, so that they become the top.
TCSS 342, Winter 2005 Lecture Notes
1 Lecture 26 Abstract Data Types – IV Overview  The List ADT  Implementing Stacks as Linked List  Linked List Implementation of Queues .  Preview:
Stacks, Queues, and Deques
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.
Stacks, Queues, and Deques. A stack is a last in, first out (LIFO) data structure –Items are removed from a stack in the reverse order from the way they.
Queues What is a Queue? Queue Implementations: Queue As Array
Stacks, Queues, and Deques
© 2004 Pearson Addison-Wesley. All rights reserved12-1 Chapter 12 : Collections Intermediate Java Programming Summer 2007.
The Stack and Queue Types Lecture 10 Hartmut Kaiser
Objectives of these slides:
90-723: Data Structures and Algorithms for Information Processing Copyright © 1999, Carnegie Mellon. All Rights Reserved. 1 Lecture 5: Stacks and Queues.
CHAPTER 05 Compiled by: Dr. Mohammad Omar Alhawarat Stacks & Queues.
Copyright © Texas Education Agency, Advanced Computer Programming Data Structures: Collections.
ISOM MIS 215 Module 3 – Stacks and Queues. ISOM Where are we? 2 Intro to Java, Course Java lang. basics Arrays Introduction NewbieProgrammersDevelopersProfessionalsDesigners.
Lists ADT (brief intro):  Abstract Data Type  A DESCRIPTION of a data type  The data type can be anything: lists, sets, trees, stacks, etc.  What.
Stacks and Queues Copyright © 2011 by Maria Litvin, Gary Litvin, and Skylight Publishing. All rights reserved. Java Methods Object-Oriented Programming.
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.
Information and Computer Sciences University of Hawaii, Manoa
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’
HIT2037- HIT6037 Software Development in Java 22 – Data Structures and Introduction.
A data structure is a type of data storage ….similar to an array. There are many data structures in Java (Stacks, Queues, LinkedList, Sets, Maps, HashTables,
COP INTERMEDIATE JAVA Data Structures. A data structure is a way of organizing a collection of data so that it can be manipulated effectively. A.
CIS3023: Programming Fundamentals for CIS Majors II Summer 2010 Ganesh Viswanathan Generics and Collections Course Lecture Slides 19 th July 2010 “Never.
Foundation of Computing Systems Lecture 3 Stacks and Queues.
1 Linked-list, stack and queue. 2 Outline Abstract Data Type (ADT)‏ Linked list Stack Queue.
CS102 – Data Structures Lists, Stacks, Queues, Trees & HashTables. David Davenport.
1 Stacks (Continued) and Queues Array Stack Implementation Linked Stack Implementation The java.util.Stack class Queue Abstract Data Type (ADT) Queue ADT.
List Interface and Linked List Mrs. Furman March 25, 2010.
Linear Data Structures
Data Structures David Kauchak cs302 Spring Data Structures What is a data structure? Way of storing data that facilitates particular operations.
1 Midterm 1 on Friday February 12 Closed book, closed notes No computer can be used 50 minutes 4 questions Write a function Write program fragment Explain.
Data Structures Lakshmish Ramaswamy. Removing Element public Object remove(int index){ Object retobj; if(index size){ throw IndexOutOfBoundsException.
Stacks as an Abstract Data Type CS1316: Representing Structure and Behavior.
Java Collections Framework The client view. The Big Picture.
1 Lecture 9: Stack and Queue. What is a Stack Stack of Books 2.
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.
QueueStack CS1020.
structures and their relationships." - Linus Torvalds
Stacks, Queues, and Deques
structures and their relationships." - Linus Torvalds
Stacks and Queues.
Stacks, Queues, and Deques
Data Structures and Algorithms for Information Processing
More Data Structures (Part 1)
Stacks, Queues, and Deques
Lecture 16 Stacks and Queues CSE /26/2018.
structures and their relationships." - Linus Torvalds
Stacks and Queues.
Lecture 9: Stack and Queue
Presentation transcript:

1/ 124 COP 3503 FALL 2012 SHAYAN JAVED LECTURE 18 Programming Fundamentals using Java 1

2/ 124 Data Structures

3/ 124 So far...  Looked at Arrays and ArrayLists as our data structures

4/ 124 So far...  Looked at Arrays and ArrayLists as our data structures  Very useful, but not always the best options

5/ 124 So far...  Looked at Arrays and ArrayLists as our data structures  Very useful, but not always the best options  Going to look at some other data structures

6/ 124 Data Structures  Stack  Queue  Linked List  Trees  Graph  Hashtable  etc.

7/ 124 Data Structures  Stack  Queue  Linked List  Trees  Graph  Hashtable  etc.

8/ 124 Stack  Last-In-First-Out (LIFO) Data Structure

9/ 124 Stack  Last-In-First-Out (LIFO) Data Structure  Basically...a stack of data.

10/ 124 Stack  Last-In-First-Out (LIFO) Data Structure  Basically...a stack of data.  Used when you want the oldest added data first.

11/ 124 Stack  Last-In-First-Out (LIFO) Data Structure  Basically...a stack of data.  Used when you want the oldest added data first.  Abstract data type (can store any kind of data).

12/ 124 Stack  Three Operations:

13/ 124 Stack  Three Operations:  push(Object): Pushes an object on top of a stack

14/ 124 Stack  Three Operations:  push(Object): Pushes an object on top of a stack  pop(): Returns the object at the top of the stack and removes it

15/ 124 Stack  Three Operations:  push(Object): Pushes an object on top of a stack  pop(): Returns the object at the top of the stack and removes it  peek(): Returns the object at the top without removing it

16/ 124 Stack  Some uses:

17/ 124 Stack  Some uses:  “Stack Frame” for method calls.

18/ 124 Stack  Some uses:  “Stack Frame” for method calls.  Used for evaluating arithmetic expressions:  (prefix, postfix, infix)

19/ 124 Stack  Java provides a Stack class (java.util.Stack)

20/ 124 Stack  Java provides a Stack class (java.util.Stack)  Has all the operations

21/ 124 Stack  Java provides a Stack class (java.util.Stack)  Has all the operations  But how does it actually store the data? (What’s the “back-end”?)

22/ 124 Stack  Java provides a Stack class (java.util.Stack)  Has all the operations  But how does it actually store the data? (What’s the “back-end”?)  Uses the java.util.Vector class (similar to ArrayList)

23/ 124 Queue  A First-In-First-Out (FIFO) data structure.

24/ 124 Queue  A First-In-First-Out (FIFO) data structure.  Used when you want the oldest added data first.

25/ 124 Queue  A First-In-First-Out (FIFO) data structure.  Used when you want the oldest added data first.  Often used for scheduling (handle first in line)

26/ 124 Queue  Three Operations:  enqueue(Object): Adds an object to the queue  dequeue(): Returns the object at the front of the queue and removes it  peek(): Returns the object at the front without removing it

27/ 124 Queue  Java provides a Queue interface (java.util.Queue)

28/ 124 Queue  Java provides a Queue interface (java.util.Queue)  Has all the operations  enqueue = add  dequeue = poll

29/ 124 Queue  Java provides a Queue interface (java.util.Queue)  Has all the operations  enqueue = add  dequeue = poll  Interface implemented in classes like LinkedList

30/ 124 Queue  Java provides a Queue interface (java.util.Queue)  Has all the operations  enqueue = add  dequeue = poll  Interface implemented in classes like LinkedList Queue queue = new LinkedList ();

31/ 124 Arrays and ArrayLists  Work well in a lot of cases.

32/ 124 Arrays and ArrayLists  Work well in a lot of cases.  Can use as “back-end” data structures

33/ 124 Arrays and ArrayLists  Work well in a lot of cases.  Can use as “back-end” data structures  But where do they fall short?

34/ 124 Arrays and ArrayLists  Work well in a lot of cases.  Can use as “back-end” data structures  But where do they fall short?  Data retrieval – excellent O(1)

35/ 124 Arrays and ArrayLists  Work well in a lot of cases.  Can use as “back-end” data structures  But where do they fall short?  Data retrieval – excellent O(1)  Adding data

36/ 124 Arrays and ArrayLists  Work well in a lot of cases.  Can use as “back-end” data structures  But where do they fall short?  Data retrieval – excellent O(1)  Adding data – inefficient O(n) in some cases

37/ 124 Arrays and ArrayLists  Work well in a lot of cases.  Can use as “back-end” data structures  But where do they fall short?  Data retrieval – excellent O(1)  Adding data – inefficient O(n) in some cases

38/ 124 Arrays and ArrayLists  Work well in a lot of cases.  Can use as “back-end” data structures  But where do they fall short?  Data retrieval – excellent O(1)  Adding data – inefficient O(n) in some cases  Fixed size – have to shift/copy to new array

39/ 124 Arrays and ArrayLists  What if your application requires a lot of adds but not retrievals?

40/ 124 Arrays and ArrayLists  What if your application requires a lot of adds but not retrievals?  Use Linked Lists

41/ 124 Linked List  A list – a collection of linked nodes.

42/ 124 Linked List  A list – a collection of linked nodes.  Dynamic data structure – size is not fixed, and memory is not contiguous (unlike an array)

43/ 124 Linked List  A list – a collection of linked nodes.  Dynamic data structure – size is not fixed, and memory is not contiguous (unlike an array)  Insertion to the list is very fast – O(1) in most cases

44/ 124 Linked List  A list – a collection of linked nodes.  Dynamic data structure – size is not fixed, and memory is not contiguous (unlike an array)  Insertion to the list is very fast – O(1) in most cases  Indexing is slow. Random access also not possible

45/ 124 Linked List  Many variations:  Singly-Linked List (can only traverse forward)  Doubly-Linked List (can traverse in reverse too)  Circular Linked Lists  Multi-Linked Lists  etc.

46/ 124 Node  Basic structure – collection of linked nodes make a linked list.

47/ 124 Node  Basic structure – collection of linked nodes make a linked list.  Stores some data and a link to the next Node.

48/ 124 Node  Basic structure – collection of linked nodes make a linked list.  Stores some data and a link to the next Node. int null

49/ 124 Node  Basic structure – collection of linked nodes make a linked list.  Stores some data and a link to the next Node. int null

50/ 124 Singly-Linked List (SLL)  Nodes connected to each other

51/ 124 Singly-Linked List (SLL)  Nodes connected to each other int null int

52/ 124 Singly-Linked List (SLL)  Nodes connected to each other  SLL only stores links to two nodes: int null int

53/ 124 Singly-Linked List (SLL)  Nodes connected to each other  SLL only stores links to two nodes:  Head node (front) int null int head

54/ 124 Singly-Linked List (SLL)  Nodes connected to each other  SLL only stores links to two nodes:  Head node (front)  Tail node (end) int null int headtail

55/ 124 Singly-Linked List (SLL)  Operations:  LinkedList():create an empty list

56/ 124 Singly-Linked List (SLL)  Operations:  LinkedList():create an empty list  append(Object):add to the end

57/ 124 Singly-Linked List (SLL)  Operations:  LinkedList():create an empty list  append(Object):add to the end  insert(Object, index):add at a certain index

58/ 124 Singly-Linked List (SLL)  Operations:  LinkedList():create an empty list  append(Object):add to the end  insert(Object, index):add at a certain index  remove(index):remove Object at index  remove(Object):remove Object

59/ 124 Singly-Linked List (SLL)  Operations:  LinkedList():create an empty list  append(Object):add to the end  insert(Object, index):add at a certain index  remove(index):remove Object at index  remove(Object):remove Object  get(Object):return index of Object  get(index):return Object at index

60/ 124 Singly-Linked List (SLL)  Operations:  LinkedList():create an empty list  append(Object):add to the end  insert(Object, index):add at a certain index  remove(index):remove Object at index  remove(Object):remove Object  get(Object):return index of Object  get(index):return Object at index  size():return size of the list

61/ 124 Singly-Linked List (SLL)  Operations:  LinkedList():create an empty list  append(Object):add to the end  insert(Object, index):add at a certain index  remove(index):remove Object at index  remove(Object):remove Object  get(Object):return index of Object  get(index):return Object at index  size():return size of the list  clear():empty the list

62/ 124 Singly-Linked List (SLL)  Create an Empty SLL:

63/ 124 Singly-Linked List (SLL)  Create an Empty SLL: headtail null

64/ 124 Singly-Linked List (SLL)  Create an Empty SLL: public SLL() { head = null; tail = null; } headtail null

65/ 124 Singly-Linked List (SLL)  append(Object):

66/ 124 Singly-Linked List (SLL)  append(Object):  Create a Node with that Object Obj null

67/ 124 Singly-Linked List (SLL)  append(Object):  Create a Node with that Object Obj null headtail

68/ 124 Singly-Linked List (SLL)  append(Object):append another object Obj null headtail

69/ 124 Singly-Linked List (SLL)  append(Object):append another object  Create a Node with that Object Obj null headtail Obj null

70/ 124 Singly-Linked List (SLL)  append(Object):append another object  Create a Node with that Object  Make tail point to it Obj headtail Obj null

71/ 124 Singly-Linked List (SLL)  append(Object):append another object  Create a Node with that Object  Make tail point to it  Update tail Node Obj headtail Obj null

72/ 124 Singly-Linked List (SLL)  size():

73/ 124 Singly-Linked List (SLL)  size(): Obj headtail Obj null Obj

74/ 124 Singly-Linked List (SLL)  size(): Obj headtail Obj null Obj temp

75/ 124 Singly-Linked List (SLL)  size(): Obj headtail Obj null Obj temp

76/ 124 Singly-Linked List (SLL)  size(): Obj headtail Obj null Obj temp

77/ 124 Singly-Linked List (SLL)  size(): Obj headtail Obj null Obj temp

78/ 124 Singly-Linked List (SLL)  size(): Obj headtail Obj null Obj temp

79/ 124 Singly-Linked List (SLL)  size():  Keep incrementing until you reach “null”. Obj headtail Obj null Obj temp

80/ 124 Singly-Linked List (SLL)  get(Object): Returns index of first Node with that object

81/ 124 Singly-Linked List (SLL)  get(Object): Returns index of first Node with that object  You should know how to traverse

82/ 124 Singly-Linked List (SLL)  get(Object): Returns index of first Node with that object  You should know how to traverse  Compare object with equals() method

83/ 124 Singly-Linked List (SLL)  get(Object): Returns index of first Node with that object  You should know how to traverse  Compare object with equals() method  Return index if found  -1 if not found

84/ 124 Singly-Linked List (SLL)  remove(Object): Obj headtail Obj null Obj

85/ 124 Singly-Linked List (SLL)  remove(Object): Obj headtail Obj null Obj

86/ 124 Singly-Linked List (SLL)  remove(Object): Obj headtail Obj null Obj

87/ 124 Singly-Linked List (SLL)  remove(Object): Obj headtail Obj null Obj

88/ 124 Singly-Linked List (SLL)  remove(Object): Obj headtail Obj null Obj

89/ 124 Singly-Linked List (SLL)  remove(Object):  remove(index)- remove at a certain index  remove(Node)- remove a certain Node  Work the same way Obj headtail Obj null Obj

90/ 124 Singly-Linked List (SLL)  So now we know how to:  append, prepend, insert

91/ 124 Singly-Linked List (SLL)  So now we know how to:  append, prepend, insert  find the size

92/ 124 Singly-Linked List (SLL)  So now we know how to:  append, prepend, insert  find the size  find the index of a specific element

93/ 124 Singly-Linked List (SLL)  So now we know how to:  append, prepend, insert  find the size  find the index of a specific element  remove an object/Node

94/ 124 Singly-Linked List (SLL)  So now we know how to:  append, prepend, insert  find the size  find the index of a specific element  remove an object/Node What about sorting?

95/ 124 Singly-Linked List (SLL)  Sorting:  Bubble Sort  Selection Sort  Insertion Sort

96/ 124 Singly-Linked List (SLL)  Sorting:  Bubble Sort  Selection Sort  Insertion Sort  How many of these can you implement for Linked Lists?

97/ 124 Singly-Linked List (SLL)  Sorting:  We should swap nodes

98/ 124 Singly-Linked List (SLL)  Sorting:  We should swap nodes Obj headtail Obj null Obj

99/ 124 Singly-Linked List (SLL)  Sorting:  We should swap nodes Obj headtail Obj null Obj

100/ 124 Singly-Linked List (SLL)  Sorting:  We should swap nodes Obj headtail Obj null Obj

101/ 124 Singly-Linked List (SLL)  Sorting:  We should swap nodes Obj headtail Obj null Obj

102/ 124 Singly-Linked List (SLL)  Sorting:  We should swap nodes Obj headtail Obj null Obj

103/ 124 Singly-Linked List (SLL)  Sorting:  We should swap nodes Obj headtail Obj null Obj

104/ 124 Singly-Linked List (SLL)  Sorting:  We should swap nodes  How many nodes were changed? Obj headtail Obj null Obj

105/ 124 Singly-Linked List (SLL)  Sorting:  We should swap nodes  How many nodes were changed? 3 Obj headtail Obj null Obj

106/ 124 Singly-Linked List (SLL)  Swap: Obj headtail Obj null Obj

107/ 124 Singly-Linked List (SLL)  Swap: Obj headtail Obj null Obj

108/ 124 Singly-Linked List (SLL)  Swap:  Also have to modify the ones before them Obj headtail Obj null Obj

109/ 124 Singly-Linked List (SLL)  Swap:  Also have to modify the ones before them Obj headtail Obj null Obj node1node2

110/ 124 Singly-Linked List (SLL)  Swap:  Also have to modify the ones before them Obj headtail Obj null Obj node1node2 node1Pnode2P

111/ 124 Singly-Linked List (SLL)  Swap: RESULT:  Also have to modify the ones before them  We have now seen two cases Obj headtail Obj null Obj node2node1 node1Pnode2P

112/ 124 Singly-Linked List (SLL) void swap(Node node1, Node node2, Node node1P, Node node2P) { if (node1.next == node2) {// side-by-side (1 st case) node1.next = node2.next; node2.next = node1; } else {// 2 nd case Node temp = node1.next; node1.next = node2.next; node2.next = temp; node2P.next = node1; } if (node1P != null)// why? node1P.next = node2; // what about the head and tail nodes? // update them accordingly }

113/ 124 Singly-Linked List (SLL) void swap(Node node1, Node node2, Node node1P, Node node2P) { if (node1.next == node2) {// side-by-side (1 st case) node1.next = node2.next; node2.next = node1; } else {// 2 nd case Node temp = node1.next; node1.next = node2.next; node2.next = temp; node2P.next = node1; } if (node1P != null)// why? node1P.next = node2; // what about the head and tail nodes? // update them accordingly }

114/ 124 Singly-Linked List (SLL) void swap(Node node1, Node node2, Node node1P, Node node2P) { if (node1.next == node2) {// side-by-side (1 st case) node1.next = node2.next; node2.next = node1; } else {// 2 nd case Node temp = node1.next; node1.next = node2.next; node2.next = temp; node2P.next = node1; } if (node1P != null)// why? node1P.next = node2; // what about the head and tail nodes? // update them accordingly }

115/ 124 Singly-Linked List (SLL) void swap(Node node1, Node node2, Node node1P, Node node2P) { if (node1.next == node2) {// side-by-side (1 st case) node1.next = node2.next; node2.next = node1; } else {// 2 nd case Node temp = node1.next; node1.next = node2.next; node2.next = temp; node2P.next = node1; } if (node1P != null)// why? node1P.next = node2; // what about the head and tail nodes? // update them accordingly }

116/ 124 Singly-Linked List (SLL) void swap(Node node1, Node node2, Node node1P, Node node2P) { if (node1.next == node2) {// side-by-side (1 st case) node1.next = node2.next; node2.next = node1; } else {// 2 nd case Node temp = node1.next; node1.next = node2.next; node2.next = temp; node2P.next = node1; } if (node1P != null)// why? node1P.next = node2; // what about the head and tail nodes? // update them accordingly }

117/ 124 Singly-Linked List (SLL) void swap(Node node1, Node node2, Node node1P, Node node2P) { if (node1.next == node2) {// side-by-side (1 st case) node1.next = node2.next; node2.next = node1; } else {// 2 nd case Node temp = node1.next; node1.next = node2.next; node2.next = temp; node2P.next = node1; } if (node1P != null)// why? node1P.next = node2; // what about the head and tail nodes? // update them accordingly }

118/ 124 Singly-Linked List (SLL) void swap(Node node1, Node node2, Node node1P, Node node2P) { if (node1.next == node2) {// side-by-side (1 st case) node1.next = node2.next; node2.next = node1; } else {// 2 nd case Node temp = node1.next; node1.next = node2.next; node2.next = temp; node2P.next = node1;// the node before node2 } if (node1P != null)// why? node1P.next = node2; // what about the head and tail nodes? // update them accordingly }

119/ 124 Singly-Linked List (SLL) void swap(Node node1, Node node2, Node node1P, Node node2P) { if (node1.next == node2) {// side-by-side (1 st case) node1.next = node2.next; node2.next = node1; } else {// 2 nd case Node temp = node1.next; node1.next = node2.next; node2.next = temp; node2P.next = node1;// the node before node2 } if (node1P != null)// why? node1P.next = node2; // what about the head and tail nodes? // update them accordingly }

120/ 124 Singly-Linked List (SLL) void swap(Node node1, Node node2, Node node1P, Node node2P) { if (node1.next == node2) {// side-by-side (1 st case) node1.next = node2.next; node2.next = node1; } else {// 2 nd case Node temp = node1.next; node1.next = node2.next; node2.next = temp; node2P.next = node1;// the node before node2 } if (node1P != null)// why? node1P.next = node2; // what about the head and tail nodes? // update them accordingly }

121/ 124 Singly-Linked List (SLL)  Sorting:  So swap is not straightforward

122/ 124 Singly-Linked List (SLL)  Sorting:  So swap is not straightforward  Once you figure out swap, you can implement Bubble and Selection Sort

123/ 124 Singly-Linked List (SLL)  Sorting:  So swap is not straightforward  Once you figure out swap, you can implement Bubble and Selection Sort  Try to implement the Sorting Methods for Linked Lists

124/ 124 Summary  Arrays/ArrayLists: useful data structures but not always optimal. Retrieval very quick, insertion can be slow  Stacks/Queues: Abstract data types useful for LIFO/FIFO storage. Implemented using arrays/SLLs  Linked Lists: Alternative to arrays – insertion is fast but retrieval is slow.