Which of the following data structures can erase from its beginning or its end in 0(1) time?
Answers
Answered by
4
Answer:
Stack
Explanation:
Answered by
1
A Circular Queue is the data structure that can erase from its beginning or its end in O(1) time.
- Assume we're removing the first node from the list. So, what's going to happen now? The second node will be at the top of the list. The linked list's shape will not be affected as a result of deleting the first node because the linked list as a whole will remain unchanged. As a result, using a linked list is out of the question.
- Let's use a binary tree as an example. The tree will be split into two trees after deleting the root node. Despite this, they have managed to keep their shape. As a result, any sort of tree will not suffice. The graph is the same way.
- If we delete the first element, the address section of the circular list's last node will lose information about the first node, because the first node has been erased. As a result, after the initial node is deleted, the circular linklist becomes a simple linked list.
- The address of only the first element is maintained to maintain the array, therefore it can also be used as an answer. As a result, if the first element is destroyed, the entire array is deleted.
#SPJ3
Similar questions
English,
4 months ago
Social Sciences,
4 months ago
Hindi,
8 months ago
Physics,
8 months ago
Hindi,
11 months ago