Queue
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:
- Operating systems for managing process scheduling.
- Networks for handling data packets.
- Print spooling in printers.
- Breadth-first search (BFS) algorithm in graph theory.
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]
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's Wellness Encyclopedia |
Let Food Be Thy Medicine Medicine Thy Food - Hippocrates |
Translate this page: - East Asian
中文,
日本,
한국어,
South Asian
हिन्दी,
தமிழ்,
తెలుగు,
Urdu,
ಕನ್ನಡ,
Southeast Asian
Indonesian,
Vietnamese,
Thai,
မြန်မာဘာသာ,
বাংলা
European
español,
Deutsch,
français,
Greek,
português do Brasil,
polski,
română,
русский,
Nederlands,
norsk,
svenska,
suomi,
Italian
Middle Eastern & African
عربى,
Turkish,
Persian,
Hebrew,
Afrikaans,
isiZulu,
Kiswahili,
Other
Bulgarian,
Hungarian,
Czech,
Swedish,
മലയാളം,
मराठी,
ਪੰਜਾਬੀ,
ગુજરાતી,
Portuguese,
Ukrainian
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