Which of the following data structures can be used to implement a queue?StackLinked listArrayBoth B and C
Question
Which of the following data structures can be used to implement a queue?
- Stack
- Linked list
- Array
- Both B and C
Solution
Both Linked list and Array can be used to implement a queue.
Here's why:
-
Linked List: A queue can be implemented using a doubly linked list. The front of the queue is equivalent to the head of the linked list and the rear of the queue is equivalent to the tail of the linked list. Enqueue operation is equivalent to insertion at the end of the linked list and Dequeue operation is equivalent to removal from the start of the linked list.
-
Array: A queue can also be implemented using an array. The front of the queue is equivalent to the first element of the array and the rear of the queue is equivalent to the last element of the array. Enqueue operation is equivalent to insertion at the end of the array and Dequeue operation is equivalent to removal from the start of the array.
Therefore, the answer is "Both B and C".
Similar Questions
Which data structure can be used to implement both stack and queue (only one data structure)
Implement linked list version of Queue data structure. Define all operations that can be performed over a queue.
How many stacks are needed to implement a queue? Consider the situation where no other data structure like arrays, linked list is available to you.ans.
. Which data structure is used for implementing recursion?a) Stackb) Queuec) Listd) Array
In C, which data structure is suitable for implementing sparse matrices?ArraysLinked ListsStacksQueues
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.