Data Structures Flashcards

1
Q

What do One-Dimensional Arrays store?

A

Store consecutive array elements of the same type in a contiguous block of memory

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

Block size formula

A

Block Size = Number of elements * Element Size

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

How do you get the Address of an element i?

A

The address for element i is:

Base address + (i * element size)

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

Where is an array allocated?

A

Like other local variables, an array is allocated in the function’s stack frame

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

How is memory used?

A

[Insert Diagram]

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

How are array elements accessed?
How can it be optimized?
What should be done if the index is a w register?

A

Using load and store instructions

[Insert Example]

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

How are individual array elements accessed in Multidimensional Arrays?

A

Using 2 or more indices

Most languages use row major order when storing arrays in RAM (First elements of row 0 then 1…)

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

The block size for an n-dimensional array is:

A

r = 1, n, pi(dim), x element size

where dim is the number of elements in dimension r

E.g. int ia[2][3][3]
Block size = (233)*4 = 72 bytes

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

The offset for a given element is?

A

[∑r = 1→ n - 1[index, x∏r+1 → n, dim] + index subscript n} x element size (where index is the index for the element in dimension r)

*NOT SURE

The offset for an element array[index1][index2][index3] is:
[[index1dim2dim3] + [index2*dim3] +index3] * element size

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

Structs contain _______ which may be of different types
Are deallocated in a ___________ of memory on the stack
Fields are accessed using ______

A

fields
single block
offsets

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

If base addresses are in x19, then the fields are accessed with?

A

[insert diagram]

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

What is a nested structure?

A

A structure that contains a field whose type is another structure

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

How are the field’s subfields accessed in Nested Structures?

A

Using a 2nd set of offsets

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

Check Notes for examples

A

.

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