Q29.Marks: +2.0UGC NET Paper 2: Computer Sc 6th Jan 2025 Shift 1
Which of the following uses only increment operations for adding and removing element at either end?
1.Queues
2.Stacks
3.Priority Queues
4.Deques✓ Correct
Solution
The correct answer is Deques.
Key Points
A deque (double-ended queue) is a data structure that allows elements to be added or removed from both ends.
Deques support insertion and deletion operations at both the front and the back, making them very flexible.
Unlike stacks and queues which are restricted to adding or removing elements from only one end, deques can perform these operations at either end using only increment operations.
This makes deques particularly useful in scenarios where elements need to be accessed, added, or removed from both ends efficiently.
Additional Information
Deques can be implemented using arrays or linked lists.
They provide a more generalized version of stacks and queues, which are limited to LIFO (Last-In-First-Out) and FIFO (First-In-First-Out) operations respectively.
Common operations in a deque include push_front(), push_back(), pop_front(), and pop_back().
In many programming languages, deques are available as part of the standard library, making them easy to use and implement.