CSC 2200 Lecture Notes - Lecture 7: Abstract Data Type
9 views4 pages
Published on 19 Jul 2018
School
Department
Course
Professor
CSC 2200 lecture 7
Queues
• Queue
o Queue is an abstract data structure, somewhat similar to Stacks.
o Unlike stacks, a queue is open at both its ends.
o One end is always used to insert data (enqueue) and the other is used to remove
data (dequeue).
o Queue follows First-In-First-Out methodology, i.e., the data item stored first will
be accessed first.
• Example
o A real-world example of queue can be a single-lane one-way road, where the
vehicle enters first, exits first.
o More real-world examples can be seen as queues at the ticket windows and bus-
stops.
• Queue representation
o As in stacks, a queue can also be implemented using Arrays, Linked-lists, Pointers
and Structures.
o For the sake of simplicity, we shall implement queues using one-dimensional
array.
• Basic operations