Array Flashcards
What is the term used to describe this?
- Series or list of variables in computer
memory - All variables share the same name and
data type - Each variable has a different subscript
Understanding Array
Arrays
Understanding Array
What is the term used to describe this?
What is the number that indicates the position of a
particular item within an array?
Understanding Array
Subscripts or
Index
Understanding Array
What is the term used to describe this?
- Each item has same name and same data type
- Each separate item is one blank an item in the array
- Array elements are contiguous in memory
How Arrays Occupy Computer Memory
Element
How Arrays Occupy Computer Memory
Is this variable initialized or uninitialized?
num someVals[3]
How Arrays Occupy Computer Memory
Uninitialized
How Arrays Occupy Computer Memory
Is this variable initialized or unintialized?
num someVals[3] = 25, 36, 47
How Arrays Occupy Computer Memory
Initialized
How Arrays Occupy Computer Memory
What is the term used to describe this?
This is the number of
elements it will
hold.
How Arrays Occupy Computer Memory
Size of the array
How Arrays Occupy Computer Memory
What is the term used to describe this?
This is the number of
elements it will
hold.
How Arrays Occupy Computer Memory
Size of the array
How Arrays Occupy Computer Memory
What is the term used to describe this?
All elements have same group name
Individual elements have blank subscript
Subscript indicates blank from first element
Subscripts are a blank of integer
How Arrays Occupy Computer Memory
unique
distance
sequence
How Arrays Occupy Computer Memory
True or False?
Subscripts placed in parentheses ( ) or brackets { }, [ ]
following group name
Syntax depends on programming language
How Arrays Occupy Computer Memory
True
How Arrays Occupy Computer Memory
True or False?
Subscripts placed in parentheses ( ) or brackets { }, [ ]
following group name
Syntax depends on programming language
How Arrays Occupy Computer Memory
True
How Arrays Occupy Computer Memory
What is this an example of?
Example: Human Resources Department Dependents report
List employees who have claimed zero through five
dependents
* Assume no employee has more than five dependents
* Application produces counts for dependent categories
* Uses series of decisions
* Application does not scale up to more dependents
Manipulating an Array to Replace Nested Decisions
Manipulating an Array to Replace Nested Decisions
Manipulating an Array to Replace Nested Decisions
True or False
Array subscript variable must be:
Numeric with no decimal places
Initialized to 0
Incremented by 1 each time the logic
passes through the loop
Manipulating an Array to Replace Nested Decisions
True
Manipulating an Array to Replace Nested Decisions
True or False
Constants are used to hold the
size of an array, its values, and as a subscript.
Using Constants with Arrays
True
Using Constants with Arrays
What is this an example of?
Avoid “magic numbers” (unnamed constants)
* Declare a named numeric constant to be used every time
array is accessed
* Make sure any subscript remains less than the constant
value
* Constant created automatically in many languages
Using Constants with Arrays
Constants
Using Constants with Arrays
What is this an example of?
Sometimes the values stored in arrays should be blank
Example:
~~~
string MONTH[12] = “January”, “February”, “March”, “April”, “May”,
“June”, “July”, “August”, “September”, “October“, “November”, “December”
~~~
Using Constants with Arrays
Constants
Using Constants with Arrays