Queue

From WikiMD's Food, Medicine & Wellness Encyclopedia

(Redirected from Queues)

Queue

A queue is a data structure used in computer science to manage a collection of elements in a specific order. The primary operations of a queue are the addition of elements to the end of the queue, known as enqueue, and the removal of elements from the front of the queue, known as dequeue. This structure follows the First In, First Out (FIFO) principle, meaning that the first element added to the queue will be the first one to be removed.

Types of Queues[edit | edit source]

There are several types of queues, each with its own specific characteristics and use cases:

  • Simple Queue: Also known as a linear queue, it allows insertion at the rear and deletion from the front.
  • Circular Queue: In this type, the last position is connected back to the first position to make a circle. It overcomes the limitation of the simple queue where no more elements can be added even if there is space at the front.
  • Priority Queue: Elements are added with a priority, and the element with the highest priority is removed first.
  • Double-ended Queue (Deque): Elements can be added or removed from both the front and the rear.

Applications[edit | edit source]

Queues are widely used in various applications, including:

Implementation[edit | edit source]

Queues can be implemented using different data structures such as arrays and linked lists. Each implementation has its own advantages and disadvantages in terms of memory usage and performance.

Array-based Implementation[edit | edit source]

In an array-based implementation, a queue is represented using an array with two pointers: front and rear. The front pointer indicates the position of the first element, and the rear pointer indicates the position where the next element will be inserted.

Linked List-based Implementation[edit | edit source]

In a linked list-based implementation, a queue is represented using a singly linked list or a doubly linked list. Each node contains the data and a reference to the next node in the sequence.

Related Concepts[edit | edit source]

See Also[edit | edit source]

Categories[edit | edit source]

Template:Data-structure-stub

Wiki.png

Navigation: Wellness - Encyclopedia - Health topics - Disease Index‏‎ - Drugs - World Directory - Gray's Anatomy - Keto diet - Recipes

Search WikiMD


Ad.Tired of being Overweight? Try W8MD's physician weight loss program.
Semaglutide (Ozempic / Wegovy and Tirzepatide (Mounjaro / Zepbound) available.
Advertise on WikiMD

WikiMD is not a substitute for professional medical advice. See full disclaimer.

Credits:Most images are courtesy of Wikimedia commons, and templates Wikipedia, licensed under CC BY SA or similar.

Contributors: Prab R. Tumpati, MD