Week 12 Dynamic & Static Data Structures Flashcards

(5 cards)

1
Q

Describe some properties of static data structures

A

Static data structures have storage size determined at compile-time / before program is run / when program code is translated / before the data structure is first used

Static data structures have fixed (maximum) size;

Static data structures can waste storage space / memory if the number of data items stored is small relative to the size of the structure

Static data structures (typically) do not need (memory to store) pointers;

Static data structures (typically) store data in consecutive memory locations;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Describe some properties of dynamic data structures

A

Dynamic data structures can grow / shrink during execution / at run-time // size of dynamic data structures can change;
Dynamic data structures only take up the amount of storage space required for the actual data;
Dynamic data structures require (memory to store) pointers to the next item(s);
Dynamic data structures (typically) do not store data in consecutive memory locations;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

State the time complexity of directly accessing an item in a dynamic and static data structure

A

O(1) for static
O(n) for dynamic

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

State two advantages of using static data structures

A

No additional memory needed for pointers;
Faster to access an item directly (O(1) vs O(n));

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

State two advantages of using dynamic data structures

A

No wasted memory;
Can grow as more data is added to the data structure // no limit on number of items that can be added (except due to hardware limitations);
Resources only allocated as they are needed (with static data structures they are allocated at creation even if not needed until later);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly