Deck 10: Arrays

Full screen (f)
exit full mode
Question
Like other variables, an array must be declared with a data type, but the number of elements it contains is not declared.
Use Space or
up arrow
down arrow
to flip the card.
Question
Declaring an array, like declaring a variable, does not necessarily give it a value.
Question
An array that has been loaded with data values is said to be "populated."
Question
Array subscripts are numbered with negative integers (whole numbers) starting with 0.
Question
You can define a numeric array named custNumber with 10 elements like this:
Declare Numeric custNumber = 10
Question
A For loop is an excellent tool for traversing an array.
Question
Because the first element has a subscript of 1, the subscripts for an array of 10 elements range from 0 to 10.
Question
In JavaScript, an array can be declared and instantiated in one statement.
Question
A limitation of the For loop is that it is designed for counter-controlled loops, in which only one condition is used to determine when to quit.
Question
The For loop's syntax makes it easy to use multiple conditions.
Question
When an array has already been sorted and you are looking for only a single match, search algorithms other than a sequential search are more efficient, even with a Boolean flag for an early exit.
Question
An easy way to create a sorted array is to increment the value of each element as you increment the subscript.
Question
A binary search will work whether or not values in the array have been sorted first.
Question
An array has a single name and data type.
Question
In arrays where values are expected to occur only once (such as ID numbers), a search normally ends when a single match is found.
Question
In arrays that might have multiple occurrences of values, such as an array of last names in a parallel array, a search normally lists all matches, along with values from other parallel arrays.
Question
An array can be thought of as a list of variables, each numbered with its subscript.
Question
A two-dimensional array has three subscripts.
Question
   -The above table represents a one-dimensional array.<div style=padding-top: 35px>

-The above table represents a one-dimensional array.
Question
A For loop works well to traverse a one-dimensional array
Question
Languages in which arrays are objects, including JavaScript, implement a two-dimensional array as an array of arrays, so separate brackets must be used for the subscripts.
Question
In JavaScript, two-dimensional arrays are implemented by making each array element contain an array object of its own.
Question
A one-dimensional array in JavaScript is an array of arrays.
Question
To assign values to a 2-D array in JavaScript, create a one-dimensional array as usual, and then add a for loop that sets each array element to an array of its own.
Question
If a two-dimensional array is organized in rows and columns, its values can be displayed row by row for easy readability.
Question
The solution for keeping multiple occurrences of similar variables is a(n) ____.

A) subscript
B) truth table
C) array
D) decision table
Question
An array is a collection of variables called ____, each with the same name and data type.

A) elements
B) subscripts
C) variables
D) sentinels
Question
A(n) ____ is a nonnegative integer used to identify an element in an array.

A) sentinel
B) subscript
C) iteration
D) counter
Question
What is the size of the following array?
Declare Numeric custNumber[10]
//Load custNumber array
CustNumber[0] = 10001
CustNumber[1] = 10643
CustNumber[2] = 10922
CustNumber[3] = 11532
CustNumber[4] = 11765

A) 2
B) 5
C) 10
D) 15
Question
Based on the information below, what is the value in the fourth position of the array?
Declare Numeric custNumber[10]

//Load custNumber array
CustNumber[0] = 10001
CustNumber[1] = 10643
CustNumber[2] = 10922
CustNumber[3] = 11532
CustNumber[4] = 11765

A) 10001
B) 10643
C) 10922
D) 11532
Question
Based on the information below, what is the value of the first element?
Declare Numeric custNumber[10]
//Load custNumber array

CustNumber[0] = 10001
CustNumber[1] = 10643
CustNumber[2] = 10922
CustNumber[3] = 11532
CustNumber[4] = 11765

A) 10001
B) 10643
C) 10922
D) 11532
Question
Based on the information below, which of the following sets the tenth element of the array to 20643?
Declare Numeric custNumber[10]

A) custNumber[10] = 20643
B) custNumber[9] = 20643
C) custNumber[8] = 20643
D) custNumber[7] = 20643
Question
Which of the following is considered an interactive array?

A) Declare Numeric numbersEntered[numEntries]
B) For index = 0 to SIZE - 1
CustNumber[index] = 0
End For

C) Declare String vegetables[] = "asparagus", "beans", "carrots"

D) Declare index
For index = 0 to SIZE - 1
Display "Enter the customer ID for subscript " + index
Input custNumber[index]
End For
Question
JavaScript arrays are objects created (instantiated) with the keyword ____.

A) var
B) new
C) start
D) Display
Question
Which of the following creates an array of five book titles?

A) var bookTitles = new Array(5);
B) var bookTitles = Array(5);
C) var bookTitles = new Array(0 to 5);
D) var SIZE = 5; var bookTitles;
BookTitles = new Array(SIZE-1);
Question
Which of the following creates an array with the elements 5, 19, 25, and 4?

A) myArray = new Array(5, 19, 25, 4);
B) var myArray = new Array(5, 19, 25, 4);
C) myArray = Array(5, 19, 25, 4);
D) var myArray = Array(5, 19, 25, 4);
Question
A shorthand notation for decrementing a variable is ____.

A) variable++
B) variable=+
C) variable--
D) variable+-
Question
A shorthand notation for incrementing a variable is ____.

A) variable++
B) variable=+
C) variable--
D) variable+-
Question
____ is the process of examining the elements of an array in order, looking for a match for a specific value.

A) Bubble sort
B) Sequential search
C) Heap sort
D) Shell sort
Question
The following algorithm depicts a ____ search.
// Prompt for customer number, search array for matches
Declare Numeric searchValue
Declare Numeric index = 0
Display "Enter the customer number you're looking for: "
Input searchValue

For index = 0 to SIZE - 1
If custNumber[index] == searchValue Then
Display "Match found at subscript: " + index
End If
End For

A) binary search
B) sequential search
C) parallel search
D) multidimensional search
Question
A search algorithm that's more efficient on large arrays-meaning it requires far fewer comparisons-is a ____.

A) sequential search
B) selection search
C) binary search
D) repetition search
Question
A ____ checks whether the search value is lower or higher than an element in the array, adjusting the limits of the array's searchable area with each comparison.

A) sequential search
B) selection search
C) binary search
D) repetition search
Question
____ use a common subscript to relate data fields.

A) Two-dimensional arrays
B) Parallel arrays
C) Multidimensional arrays
D) Single arrays
Question
____ arrays have a single name and data type, but they use two or more subscripts to identify a particular element.

A) Multidimensional
B) Single
C) Parallel
D) Sequential
Question
Which of the following statements is correct?

A) Case structures are ideal for traversing two-dimensional arrays.
B) Nested For loops are ideal for traversing two-dimensional arrays.
C) Do while loops are ideal for traversing two-dimensional arrays.
D) Nested For loops are ideal for traversing one-dimensional arrays.
Question
JavaScript uses which of the following notations for the first element of a two-dimensional array: ____.

A) [0][1]
B) [1][0]
C) [0][0]
D) [1][1]
Question
Based on the information below, how would you access the first index of the array?
Var x = [0, 1, 2, 3, 4, 5];
Var y = [x];

A) document.write(y[0]);
B) document.write(y[0][0]);
C) document.write(y[3]);
D) document.write(y[0][1]);
Question
Based on the information below, what is the value of the third index array x?
Var x = [0, 1, 2, 3, 4, 5];
Var y = [x];

A) 0
B) 1
C) 2
D) 3
Question
Which of the following is a three-dimensional array?

A) var SIZE = 5000000;
Var numberArray = new Array(SIZE);

B) Declare Constant SIZE = 1000
Declare Numeric empNumber[SIZE]
Declare String empLastName[SIZE], empFirstName[SIZE]
Declare Numeric index
Declare String moreInput = "Y"
For index = 0 to SIZE - 1
EmpNumber[index] = 0
EmpLastName[index] = ""
EmpFirstName[index] = ""
End For

C) var ROWS = 4;
Var COLUMNS = 6;
Var scores = new Array(ROWS);
For (index = 0; index < ROWS; index++) {
Scores[index] = new Array(COLUMNS);
}

D) var cube = new Array();
Cube[0] = new Array();
Cube[0][0] = new Array();
Question
Which of the following will cause a syntax error?

A) for (index = 0; index < 6000000;) {
X = 123.456789 / 987.654321;
}

B) numberArray = new Array(SIZE);

C) for (index = 0; index < SIZE; index++) {
NumberArray[index] = index + 1;
}

D) for (index = 0; index < SIZE; index++) {
BookTitles[index] = prompt
("Enter title for book #" + (index + 1) + ":",ES);
}
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/50
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 10: Arrays
1
Like other variables, an array must be declared with a data type, but the number of elements it contains is not declared.
False
2
Declaring an array, like declaring a variable, does not necessarily give it a value.
True
3
An array that has been loaded with data values is said to be "populated."
True
4
Array subscripts are numbered with negative integers (whole numbers) starting with 0.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
5
You can define a numeric array named custNumber with 10 elements like this:
Declare Numeric custNumber = 10
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
6
A For loop is an excellent tool for traversing an array.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
7
Because the first element has a subscript of 1, the subscripts for an array of 10 elements range from 0 to 10.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
8
In JavaScript, an array can be declared and instantiated in one statement.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
9
A limitation of the For loop is that it is designed for counter-controlled loops, in which only one condition is used to determine when to quit.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
10
The For loop's syntax makes it easy to use multiple conditions.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
11
When an array has already been sorted and you are looking for only a single match, search algorithms other than a sequential search are more efficient, even with a Boolean flag for an early exit.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
12
An easy way to create a sorted array is to increment the value of each element as you increment the subscript.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
13
A binary search will work whether or not values in the array have been sorted first.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
14
An array has a single name and data type.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
15
In arrays where values are expected to occur only once (such as ID numbers), a search normally ends when a single match is found.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
16
In arrays that might have multiple occurrences of values, such as an array of last names in a parallel array, a search normally lists all matches, along with values from other parallel arrays.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
17
An array can be thought of as a list of variables, each numbered with its subscript.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
18
A two-dimensional array has three subscripts.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
19
   -The above table represents a one-dimensional array.

-The above table represents a one-dimensional array.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
20
A For loop works well to traverse a one-dimensional array
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
21
Languages in which arrays are objects, including JavaScript, implement a two-dimensional array as an array of arrays, so separate brackets must be used for the subscripts.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
22
In JavaScript, two-dimensional arrays are implemented by making each array element contain an array object of its own.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
23
A one-dimensional array in JavaScript is an array of arrays.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
24
To assign values to a 2-D array in JavaScript, create a one-dimensional array as usual, and then add a for loop that sets each array element to an array of its own.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
25
If a two-dimensional array is organized in rows and columns, its values can be displayed row by row for easy readability.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
26
The solution for keeping multiple occurrences of similar variables is a(n) ____.

A) subscript
B) truth table
C) array
D) decision table
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
27
An array is a collection of variables called ____, each with the same name and data type.

A) elements
B) subscripts
C) variables
D) sentinels
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
28
A(n) ____ is a nonnegative integer used to identify an element in an array.

A) sentinel
B) subscript
C) iteration
D) counter
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
29
What is the size of the following array?
Declare Numeric custNumber[10]
//Load custNumber array
CustNumber[0] = 10001
CustNumber[1] = 10643
CustNumber[2] = 10922
CustNumber[3] = 11532
CustNumber[4] = 11765

A) 2
B) 5
C) 10
D) 15
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
30
Based on the information below, what is the value in the fourth position of the array?
Declare Numeric custNumber[10]

//Load custNumber array
CustNumber[0] = 10001
CustNumber[1] = 10643
CustNumber[2] = 10922
CustNumber[3] = 11532
CustNumber[4] = 11765

A) 10001
B) 10643
C) 10922
D) 11532
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
31
Based on the information below, what is the value of the first element?
Declare Numeric custNumber[10]
//Load custNumber array

CustNumber[0] = 10001
CustNumber[1] = 10643
CustNumber[2] = 10922
CustNumber[3] = 11532
CustNumber[4] = 11765

A) 10001
B) 10643
C) 10922
D) 11532
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
32
Based on the information below, which of the following sets the tenth element of the array to 20643?
Declare Numeric custNumber[10]

A) custNumber[10] = 20643
B) custNumber[9] = 20643
C) custNumber[8] = 20643
D) custNumber[7] = 20643
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
33
Which of the following is considered an interactive array?

A) Declare Numeric numbersEntered[numEntries]
B) For index = 0 to SIZE - 1
CustNumber[index] = 0
End For

C) Declare String vegetables[] = "asparagus", "beans", "carrots"

D) Declare index
For index = 0 to SIZE - 1
Display "Enter the customer ID for subscript " + index
Input custNumber[index]
End For
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
34
JavaScript arrays are objects created (instantiated) with the keyword ____.

A) var
B) new
C) start
D) Display
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
35
Which of the following creates an array of five book titles?

A) var bookTitles = new Array(5);
B) var bookTitles = Array(5);
C) var bookTitles = new Array(0 to 5);
D) var SIZE = 5; var bookTitles;
BookTitles = new Array(SIZE-1);
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
36
Which of the following creates an array with the elements 5, 19, 25, and 4?

A) myArray = new Array(5, 19, 25, 4);
B) var myArray = new Array(5, 19, 25, 4);
C) myArray = Array(5, 19, 25, 4);
D) var myArray = Array(5, 19, 25, 4);
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
37
A shorthand notation for decrementing a variable is ____.

A) variable++
B) variable=+
C) variable--
D) variable+-
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
38
A shorthand notation for incrementing a variable is ____.

A) variable++
B) variable=+
C) variable--
D) variable+-
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
39
____ is the process of examining the elements of an array in order, looking for a match for a specific value.

A) Bubble sort
B) Sequential search
C) Heap sort
D) Shell sort
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
40
The following algorithm depicts a ____ search.
// Prompt for customer number, search array for matches
Declare Numeric searchValue
Declare Numeric index = 0
Display "Enter the customer number you're looking for: "
Input searchValue

For index = 0 to SIZE - 1
If custNumber[index] == searchValue Then
Display "Match found at subscript: " + index
End If
End For

A) binary search
B) sequential search
C) parallel search
D) multidimensional search
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
41
A search algorithm that's more efficient on large arrays-meaning it requires far fewer comparisons-is a ____.

A) sequential search
B) selection search
C) binary search
D) repetition search
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
42
A ____ checks whether the search value is lower or higher than an element in the array, adjusting the limits of the array's searchable area with each comparison.

A) sequential search
B) selection search
C) binary search
D) repetition search
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
43
____ use a common subscript to relate data fields.

A) Two-dimensional arrays
B) Parallel arrays
C) Multidimensional arrays
D) Single arrays
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
44
____ arrays have a single name and data type, but they use two or more subscripts to identify a particular element.

A) Multidimensional
B) Single
C) Parallel
D) Sequential
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
45
Which of the following statements is correct?

A) Case structures are ideal for traversing two-dimensional arrays.
B) Nested For loops are ideal for traversing two-dimensional arrays.
C) Do while loops are ideal for traversing two-dimensional arrays.
D) Nested For loops are ideal for traversing one-dimensional arrays.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
46
JavaScript uses which of the following notations for the first element of a two-dimensional array: ____.

A) [0][1]
B) [1][0]
C) [0][0]
D) [1][1]
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
47
Based on the information below, how would you access the first index of the array?
Var x = [0, 1, 2, 3, 4, 5];
Var y = [x];

A) document.write(y[0]);
B) document.write(y[0][0]);
C) document.write(y[3]);
D) document.write(y[0][1]);
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
48
Based on the information below, what is the value of the third index array x?
Var x = [0, 1, 2, 3, 4, 5];
Var y = [x];

A) 0
B) 1
C) 2
D) 3
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
49
Which of the following is a three-dimensional array?

A) var SIZE = 5000000;
Var numberArray = new Array(SIZE);

B) Declare Constant SIZE = 1000
Declare Numeric empNumber[SIZE]
Declare String empLastName[SIZE], empFirstName[SIZE]
Declare Numeric index
Declare String moreInput = "Y"
For index = 0 to SIZE - 1
EmpNumber[index] = 0
EmpLastName[index] = ""
EmpFirstName[index] = ""
End For

C) var ROWS = 4;
Var COLUMNS = 6;
Var scores = new Array(ROWS);
For (index = 0; index < ROWS; index++) {
Scores[index] = new Array(COLUMNS);
}

D) var cube = new Array();
Cube[0] = new Array();
Cube[0][0] = new Array();
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
50
Which of the following will cause a syntax error?

A) for (index = 0; index < 6000000;) {
X = 123.456789 / 987.654321;
}

B) numberArray = new Array(SIZE);

C) for (index = 0; index < SIZE; index++) {
NumberArray[index] = index + 1;
}

D) for (index = 0; index < SIZE; index++) {
BookTitles[index] = prompt
("Enter title for book #" + (index + 1) + ":",ES);
}
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 50 flashcards in this deck.