Data structures Flashcards

1
Q

Advantage of dynamic memory allocation vs static memory allocation

A
  1. Dynamic memory allocation is more efficient in terms of memory usage because only the amount of memory required is being allocated upon request, while in static memory allocation, not all the allocated memory might be used up.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Problems of dynamic memory allocation

A
  1. Run out of storage
  2. Memory fragmentation; Free space is fragmented, meaning that despite total available memory being large, it is split up into many blocks of small memory
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Advantages of static vs dynamic memory allocation

A
  1. Static is contiguous; able to address each location as an index
  2. Static has lower overhead as no need additional memory to store pointers
  3. Static has less memory requests
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How to draw BST if root node is deleted?

A
  1. Find largest left OR smallest right, this value will be the new root
  2. Add the other side to the right/left
How well did you know this?
1
Not at all
2
3
4
5
Perfectly