Arrays Flashcards

1
Q

Data structure that stores data of the same type

A

Array

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

Elements of an array are arranged ______

A

contiguously(in sequence)

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

Each element of an array can be considered as ________

A

one variable

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

Types of Arrays (2)

A

Static
Dynamic

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

Size of an array is defined during the array declaration

A

Static Array

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

Size of the array is determined during run time.

Uses a pointer

A

Dynamic Array

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

Static Array Syntax

A

<dataType> <arrName>[<size>];
</size></arrName></dataType>

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

Static Array Initialization

A

<dataType> <arrName>[<size>] = {<val1>, <val2>, ...};
</val2></val1></size></arrName></dataType>

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

Missing values of a static array will be given the value of ___

A

zero

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

Allows you to access the value of an element in an array given its index

A

Array Jndexing

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

Arrays have a ________ indexing; index starts at 0.

A

zero-based

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

Valid indices

A
  1. non- negative integers
  2. integers from 0 to size-1
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Another way of accessing array values.
Done using asterisks and parentheses.

A

Pointer Arithmetic

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

Pointer Arithmetic Syntax

A

arrName[index] = *(arrName + index)

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

Uses pointers as well as the malloc() and free() functions

A

Dynamic Arrays

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

Allocates memory locations as requested by the program.

Included in the stdlib.h header file.

Returns the address of the first element of the allocated memory cells.

A

malloc()

17
Q

malloc() syntax

A

malloc(sizeof(<dataType>)*<size>);</size></dataType>

18
Q

Deallocates the memory allocated via malloc()

Included in the stdlib.h header file

A

free()

19
Q

free() Syntax

A

free(<pointerToArray>);</pointerToArray>