Collection
Queue
A linear collection following the First-In-First-Out (FIFO) principle, supporting operations like enqueue and dequeue, useful in task scheduling.
- Time complexity for access and search is Linear, i.e. O(n)
- Time complexity for insertion and deletion is Constant, i.e. O(n)
- Space complexity is Linear
Stack
A stack is a linear data structure that follows the Last In First Out (LIFO) principle. Elements are added and removed from the same end, called the top. Common operations include push (add an element), pop (remove the top element), and peek (view the top element without removing it). Stacks are used in various applications like function call management, expression evaluation, and backtracking.