Abstract Data Types Flashcards
1
Q
Advantages of Stack Implementation using Array
A
- Simple implementation
- Constant time: O(1)
- Better cache locality
2
Q
Disadvantages of Stack Implementation using Array
A
- Fixed size with maximum capacity
- Cost of Resizing: O(n)
- Wasted memory
- Not suitable for applications where the size of the stack is not known in advance
3
Q
Advantages of Stack Implementation using Linked List
A
- Dynamic size
- No preallocation
- Easy resizing: O(1)
4
Q
Disadvantages of Stack Implementation using Linked List
A
- Memory overhead due to the storage of pointers
- Poor cache locality
5
Q
Choice of Stack Implementation
A
- If stack size is known -> Array-based
- If the stack varies dynamically ->linked list
- If efficient memory access and cache locality -> Array-based
6
Q
A