Abstract Data Types Flashcards

1
Q

Advantages of Stack Implementation using Array

A
  1. Simple implementation
  2. Constant time: O(1)
  3. Better cache locality
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Disadvantages of Stack Implementation using Array

A
  1. Fixed size with maximum capacity
  2. Cost of Resizing: O(n)
  3. Wasted memory
  4. Not suitable for applications where the size of the stack is not known in advance
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Advantages of Stack Implementation using Linked List

A
  1. Dynamic size
  2. No preallocation
  3. Easy resizing: O(1)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Disadvantages of Stack Implementation using Linked List

A
  1. Memory overhead due to the storage of pointers
  2. Poor cache locality
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Choice of Stack Implementation

A
  1. If stack size is known -> Array-based
  2. If the stack varies dynamically ->linked list
  3. If efficient memory access and cache locality -> Array-based
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly