Array-Based Sequences Flashcards

1
Q

examples of Python’s built-in ‘sequence’ classes

A

list, tuple, str

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

memory address

A

(an abstraction) computer system keeps track of what information is stored in each byte - each byte of mem associated w/ unique number

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

RAM

A

(how computer’s main memory performs) each byte of memory can be efficiently accessed regardless of address

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

array

A

group of related variables stored 1 after another in contiguous portion

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

why each cell of array uses same number of bytes?

A

can access in constant time (based on index): appropriate memory address —–>
start + cellsize*index

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

referential arrays

A

stores consecutive sequences of memory addresses at which elements of sequence reside (lists & tuples) - rel size of indiv ele’s may vary, but bits used to store mem addr’s is fixed

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

compact arrays

A

stores the bits that represent the primary data

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

advantages of compact over referential arrays

A
  • overall memory lower (no overhead devoted to explicit storage of seq of mem ref’s)
  • primary data stored consecutively in memory (not case w/ referential)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

dynamic array

A

can change precise size of array (ie. list)

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

low-level array

A

size of array must be explicitly declared (cannot expand into subsequent cells)

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

why tuples more memory efficient than lists

A

immutable - no need for an underlying dynamic array w/ surplus capacity

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

shallow copy

A

references the SAME elements (with immutable ele’s, point is moot)

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

deep copy

A

has NEW elements (deepcopy function from copy module)

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

extend method for lists

A

receives ref’s to the ele’s (not copies of the ele’s)

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

amortization/amortized analysis

A

many simple, efficient op’s for each expensive op (ie. list append method exhibits amortized constant-time behavior)

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