Nerd For Tech

NFT is an Educational Media House. Our mission is to bring the invaluable knowledge and experiences…

Member-only story

What are Queues in Programming?

Akiko Green
Nerd For Tech
Published in
6 min readFeb 23, 2023

--

image of people from Unsplash by halacious

The best way to think about a Queue in programming is to visualize a line of people waiting for entry to a venue.

A queue is a linear data structure open at both ends where we can perform a First In, First Out (FIFO) order. Visually speaking, the first person in line, will also be the the first person out of line.

Now, before I get into explaining how to implement a Queue data structure. I’d like to mention that this is for those who just started learning about data structures :).

How To Implement A Queue

There are two ways to implement a queue. We can either use an Array or a Linked List.

Array Advantages & Disadvantages

Advantages of implementing a queue with an array:

  • Simplicity: Implementing a queue with an array is straightforward and easy to understand.
  • Random access: Array-based implementation allows for random access, which means that we can directly access the i-th element of the queue using its index.
  • Efficiency: Array-based implementation can be more efficient in terms of memory usage and time complexity when compared to linked lists. Specifically, arrays require less memory overhead, and they have better locality of reference, which can…

--

--

Nerd For Tech
Nerd For Tech

Published in Nerd For Tech

NFT is an Educational Media House. Our mission is to bring the invaluable knowledge and experiences of experts from all over the world to the novice. To know more about us, visit https://www.nerdfortech.org/.

Akiko Green
Akiko Green

Written by Akiko Green

Software Engineer, Novice Blogger, Indoor Climber and Dog sitting expert 🥰

No responses yet