Chapter 6: Arrays Flashcards

(13 cards)

1
Q

What are the design issues for arrays?

A

Issues include
- legal subscript types
- range checking of subscripts
- when are subscript ranges bound?
- when does array allocation take place?
- are ragged or rectangular multidimensioned arrays allowed, or both?
- allowed slice types.

.

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

Define static, fixed stack-dynamic, stack-dynamic, fixed heap-dynamic, and heap-dynamic arrays. What are the advantages of each?

A

Static: Subscript ranges and storage are bound before run time. Advantage: Efficiency (no dynamic allocation).

Fixed stack-dynamic: Storage is allocated at declaration time, but size is static. Advantage: Space efficiency.

Stack-dynamic: Range and storage are bound dynamically at run time. Advantage: Flexibility.

Fixed heap-dynamic: Subscript ranges and storage binding are fixed after allocation from the heap. Advantage: Flexibility (size fits the problem).

Heap-dynamic: Subscript ranges and storage allocation can change during execution. Advantage: Maximum flexibility.

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

What happens when a nonexistent element of an array is referenced in Perl?

A

It yields undef, but no error is reported.

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

What languages support negative subscripts?

A

Ruby, Lua, and Perl.

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

What languages support array slices with stepsizes?

A

Python.

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

What array initialization feature is available in Ada that is not available in other common imperative languages?

A

Ada allows initializing specific indices directly using the arrow operator => and an others clause for remaining elements.

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

What is an aggregate constant?

A

A parenthesized list of values used to initialize an array.

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

What array operations are provided specifically for single-dimensioned arrays in Ada?

A

Catenation (specified by &).

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

Define row major order and column major order.

A

Row major: Elements are stored by rows (first subscript varies slowest).
Column major: Elements are stored by columns (last subscript varies slowest).

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

What is an access function for an array?

A

It is a mapping from the array name and set of subscript values to the address of an element.

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

What are the required entries in a Java array descriptor, and when must they be stored?

A

It requires the fixed maximum length and current length, stored at run time (because Java arrays are fixed heap-dynamic).

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

What is the structure of an associative array?

A

It is an unordered collection of data elements indexed by an equal number of keys (each element is a key-value pair).

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

How does JavaScript support sparse arrays?

A

JavaScript supports sparse arrays by treating them as objects containing specific items, not as a reserved block of empty space.

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