4.2.3

Queues

Test yourself

Queues

A queue is a data structure where data items are always added to the end and removed from the front. It is often referred to as a 'first in, first out’ data structure.

Illustrative background for QueuesIllustrative background for Queues ?? "content

Queues

  • Queues can be implemented using other data structures, such as arrays or linked lists.
  • In either case, two extra variables are required to identify the front and rear of the queue.
  • Queues can be ‘static’ (fixed in size) or ‘dynamic’ (able to grow in size as necessary)
Illustrative background for Queue operationsIllustrative background for Queue operations ?? "content

Queue operations

  • Several operations can be carried out on queues:
    • enQueue() - adds an item to the rear of a queue.
    • deQueue() - removes and displays the item at the front of a queue.
    • isEmpty() - checks to see if the queue is empty.
    • isFull() - checks to see if the queue is full.
Illustrative background for UsesIllustrative background for Uses ?? "content

Uses

  • Queues have a wide range of uses in computer science, including:
    • Storing print jobs until the printer is ready to print.
    • CPU scheduling.
    • Breadth-first traversal of a graph.
Illustrative background for Linear or circularIllustrative background for Linear or circular ?? "content

Linear or circular

  • Queues can also be ‘linear’ or ‘circular’.
  • When an item of data is removed from the front of a linear queue, all the other items move up one place.
    • This is only suitable in a small queue, otherwise data processing time can be excessive.
  • When an item of data is removed from the front of a circular queue, the only processing required is to update the two pointers identifying the new front and rear of the queue.

Jump to other topics

1Components of a Computer

2Software & Software Development

3Exchanging Data

4Data Types, Data Structures & Algorithms

5Legal, Moral, Cultural & Ethical Issues

6Elements of Computational Thinking

6.1Thinking Abstractly

6.2Thinking Ahead

6.3Thinking Procedurally

6.4Thinking Logically

6.5Thinking Concurrently

7Problem Solving & Programming

8Algorithms

Unlock your full potential with Seneca Premium

  • Unlimited access to 10,000+ open-ended exam questions

  • Mini-mock exams based on your study history

  • Unlock 800+ premium courses & e-books

Get started with Seneca Premium