Deck 5: Arrays
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/50
Play
Full screen (f)
Deck 5: Arrays
1
As with a while loop,when you use a for loop,you must be careful to stay within array bounds.
True
2
In most modern programming languages,the highest subscript you should use with an 8-element array is ____ .
A) 6
B) 7
C) 8
D) 9
A) 6
B) 7
C) 8
D) 9
B
3
A(n)____ is a contiguous series of variables in computer memory.
A) collection
B) matrix
C) vector
D) array
A) collection
B) matrix
C) vector
D) array
D
4
Any array's subscripts are always a ____ of integers.
A) group
B) sequence
C) list
D) range
A) group
B) sequence
C) list
D) range
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
5
Each individual element in an array has a unique ____ indicating how far away it is from the first element.
A) indicator
B) element
C) subscript
D) script
A) indicator
B) element
C) subscript
D) script
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
6
The smaller the array,the more beneficial it becomes to exit the searching loop as soon as you find what you're looking for.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
7
The number of elements an array will hold is known as the ____ of the array.
A) bounds
B) limits
C) constraints
D) size
A) bounds
B) limits
C) constraints
D) size
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
8
The values stored in arrays should never be constants.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
9
All array elements have the same ____ name.
A) group
B) target
C) structure
D) collection
A) group
B) target
C) structure
D) collection
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
10
All the variables in an array are differentiated with special numbers called ____.
A) scripts
B) subscripts
C) elements
D) pointers
A) scripts
B) subscripts
C) elements
D) pointers
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
11
When you create parallel arrays,each array must be of the same data type.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
12
Each separate array variable is one ____ of the array.
A) element
B) aspect
C) index
D) member
A) element
B) aspect
C) index
D) member
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
13
Subscripts begin with a value of ____.
A) -1
B) 0
C) 1
D) the number of elements in the array
A) -1
B) 0
C) 1
D) the number of elements in the array
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
14
A(n)____,also called an index,is a number that indicates the position of a particular item within an array.
A) indicator
B) element
C) subscript
D) script
A) indicator
B) element
C) subscript
D) script
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
15
Subscript values can be negative integers in all languages.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
16
If you assume an array's first subscript is 0,you will always be "off by one" in your array manipulation.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
17
You cannot initialize array elements when you declare the array.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
18
Each array element occupies an area in memory next to the others.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
19
In many languages,when you declare an array,a constant that represents the array size is automatically created for you.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
20
All the variables in an array have the same name and data type.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
21
An element in an array is 3 bytes long and there are 10 elements in the array.How big is the array?
A) 30 bytes
B) 10 bytes
C) 3 bytes
D) Not enough information to determine
A) 30 bytes
B) 10 bytes
C) 3 bytes
D) Not enough information to determine
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
22
When declaring an array,depending on the syntax rules of the programming language you use,you place the subscript within parentheses or ____ following the group name.
A) asterisks
B) slashes
C) curly brackets
D) square brackets
A) asterisks
B) slashes
C) curly brackets
D) square brackets
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
23
A ____ search starts looking in the middle of a sorted list,and then determines whether it should continue higher or lower.
A) linear
B) quick
C) graphic
D) binary
A) linear
B) quick
C) graphic
D) binary
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
24
When you search through a list from one end to the other,you are performing a ____ search.
A) linear
B) binary
C) quick
D) Google
A) linear
B) binary
C) quick
D) Google
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
25
In Java,C++,and C#,the for loop looks like the following:
A) for(dep = 0; dep++; dep < SIZE)
B) for(dep > SIZE; dep = 0; dep++)
C) for(dep = 0; dep < SIZE; dep++)
D) for(dep = SIZE,dep > 0,dep++)
A) for(dep = 0; dep++; dep < SIZE)
B) for(dep > SIZE; dep = 0; dep++)
C) for(dep = 0; dep < SIZE; dep++)
D) for(dep = SIZE,dep > 0,dep++)
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
26
Learning to use arrays correctly can make many programming tasks far more ____ and professional.
A) confusing
B) efficient
C) slick
D) literal
A) confusing
B) efficient
C) slick
D) literal
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
27
The ____ is a particularly convenient tool when working with arrays because you frequently need to process every element of an array from beginning to end.
A) binary search
B) range check
C) for loop
D) parallel array
A) binary search
B) range check
C) for loop
D) parallel array
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
28
Leaving a loop as soon as a match is found improves the program's ____.
A) indirect relationships
B) logic
C) simplicity
D) efficiency
A) indirect relationships
B) logic
C) simplicity
D) efficiency
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
29
Frequently,a flag holds a ____ value.
A) subscript
B) true or false
C) string
D) junk
A) subscript
B) true or false
C) string
D) junk
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
30
The relationship between an item's number and its price is a(n)____ relationship.
A) direct
B) indirect
C) hidden
D) clear
A) direct
B) indirect
C) hidden
D) clear
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
31
Besides making your code easier to modify,using a ____ makes the code easier to understand.
A) constant
B) named constant
C) named declaration
D) named variable
A) constant
B) named constant
C) named declaration
D) named variable
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
32
When you use parallel arrays,a ____ relates the arrays.
A) link
B) flag
C) subscript
D) script
A) link
B) flag
C) subscript
D) script
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
33
When you use parallel arrays,two or more arrays contain ____ data.
A) connected
B) equivalent
C) identical
D) related
A) connected
B) equivalent
C) identical
D) related
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
34
A ____ is a variable that you set to indicate whether some event has occurred.
A) handler
B) rudder
C) flag
D) bug
A) handler
B) rudder
C) flag
D) bug
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
35
Most programming languages use a statement similar to the following to declare a three-element array and assign values to it: ____
A) {20,30,40} = num someVals[3]
B) num someVals[3] = {someVals}
C) num someVals[] = 20,30,40
D) num someVals[3] = 20,30,40
A) {20,30,40} = num someVals[3]
B) num someVals[3] = {someVals}
C) num someVals[] = 20,30,40
D) num someVals[3] = 20,30,40
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
36
When working with arrays,you can use ____ in two ways: to hold an array's size and as the array values.
A) structures
B) literals
C) constants
D) strings
A) structures
B) literals
C) constants
D) strings
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
37
The true benefit of an array lies in your ability to use a(n)____ as a subscript to the array.
A) variable
B) table
C) operator
D) field
A) variable
B) table
C) operator
D) field
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
38
In ____ arrays,each element in one array is associated with the element in the same relative position in the other array.
A) parallel
B) related
C) grouped
D) combined
A) parallel
B) related
C) grouped
D) combined
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
39
When you have a six element array and use subscript 6,your subscript is said to be out of ____.
A) bounds
B) scope
C) range
D) array
A) bounds
B) scope
C) range
D) array
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
40
What is TRUE about the following array? num someVals[5] = 1,3,5,7,9
A) someVals[1] has the value of 1
B) someVals[1] has the value of 3
C) There are 6 elements in this array.
D) someVals[3] has the value of 3
A) someVals[1] has the value of 1
B) someVals[1] has the value of 3
C) There are 6 elements in this array.
D) someVals[3] has the value of 3
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
41
The following pseudocode is not working correctly.The code should total the array elements.What code needs to be changed? start
Declarations
Num count = 0
Num total = 0
Num scores[6] = 2,4,6,8,10,12
While count < 6
Total = total + scores
Count = count + 1
Endwhile
Stop
A) Change the while to:
While count < 7
B) move count = count + 1 after the endwhile
C) Change the total = to:
Total = scores + scores[count]
D) Change the total = to:
Total = total + scores[count]
Declarations
Num count = 0
Num total = 0
Num scores[6] = 2,4,6,8,10,12
While count < 6
Total = total + scores
Count = count + 1
Endwhile
Stop
A) Change the while to:
While count < 7
B) move count = count + 1 after the endwhile
C) Change the total = to:
Total = scores + scores[count]
D) Change the total = to:
Total = total + scores[count]
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
42
The following pseudocode is not working correctly.How should the for loop be changed? start
Declarations
Num count = 0
Num scores[6] = 0,0,0,0,0,0
Num SIZE = 6
For count 0 to SIZE step
Input entry
Scores[count] = entry
Endfor
Stop
A) for count 0 to SIZE + 1 step 1
B) for count 0 to SIZE - 1 step 1
C) for count 0 to SIZE - 1 step
D) for count 0 to SIZE - 1 step -1
Declarations
Num count = 0
Num scores[6] = 0,0,0,0,0,0
Num SIZE = 6
For count 0 to SIZE step
Input entry
Scores[count] = entry
Endfor
Stop
A) for count 0 to SIZE + 1 step 1
B) for count 0 to SIZE - 1 step 1
C) for count 0 to SIZE - 1 step
D) for count 0 to SIZE - 1 step -1
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
43
You are working with parallel arrays to detemine the grade a student earns in a class.The student earns a grade based on the following: minimum points to earn an A is 900
Minimum points to earn a B is 800
Minimum points to earn a C is 700
Minimum points to earn a D is 600
Below 600 earns an F
The points array is defined as follows: num points[5] = 900,800,700,600,0
How should the grades array be defined?
A) num grades[5] = A,B,C,D,F
B) string grades[5] = "A","B","C","D","F"
C) num grades[5] = "A","B","C","D","F"
D) string grades[5] = "F","D","C","B","A"
Minimum points to earn a B is 800
Minimum points to earn a C is 700
Minimum points to earn a D is 600
Below 600 earns an F
The points array is defined as follows: num points[5] = 900,800,700,600,0
How should the grades array be defined?
A) num grades[5] = A,B,C,D,F
B) string grades[5] = "A","B","C","D","F"
C) num grades[5] = "A","B","C","D","F"
D) string grades[5] = "F","D","C","B","A"
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
44
Write the pseudocode to define a five element array called "scores," and then allow a user to enter 5 scores and store them in the array using a while loop.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
45
Write the pseudocode to define and initialize a five element array called "evens," with even numbers from 2 to 10,and then find the total of the values in the array using a for loop.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
46
The following pseudocode checks if an item number is valid: start
Declarations
Num sub = 0
Num SIZE = 5
Num VALID_ITEM [5] = 27,53,84,89,95
String foundIt = "N"
Input item
While sub < SIZE
If item = VALID_ITEM[sub] then
FoundIt = "Y"
Endif
Sub = sub +1
Endwhile
If foundIt = "Y" then
Output "Valid item number"
Else
Output "Invalid item number"
Endif
Stop
Which while loop makes this more efficient?
A) while sub < SIZE AND foundIt = "N"
B) while sub < SIZE AND foundIt > "N"
C) while sub < SIZE AND foundIt = "Y"
D) The while loop is already efficient
Declarations
Num sub = 0
Num SIZE = 5
Num VALID_ITEM [5] = 27,53,84,89,95
String foundIt = "N"
Input item
While sub < SIZE
If item = VALID_ITEM[sub] then
FoundIt = "Y"
Endif
Sub = sub +1
Endwhile
If foundIt = "Y" then
Output "Valid item number"
Else
Output "Invalid item number"
Endif
Stop
Which while loop makes this more efficient?
A) while sub < SIZE AND foundIt = "N"
B) while sub < SIZE AND foundIt > "N"
C) while sub < SIZE AND foundIt = "Y"
D) The while loop is already efficient
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
47
Define and initialize an array that contains the names of the days of the week.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
48
Write the pseudocode to define and initialize a four element array called "evens," with even numbers from 2 to 8,and then find the total of the values in the array using a while loop.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
49
Write the pseudocode to define a six element array called "scores," and then allow a user to enter 6 scores and store them in the array using a for loop.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
50
The following pseudocode is not working correctly.What kind of error is this? start
Declarations
Num count = 0
Num scores[6] = 0,0,0,0,0,0
Num SIZE = 6
For count 0 to SIZE step 1
Input entry
Scores[count] = entry
Endfor
Stop
A) out of memory
B) no match was found
C) out of bounds
D) bounded
Declarations
Num count = 0
Num scores[6] = 0,0,0,0,0,0
Num SIZE = 6
For count 0 to SIZE step 1
Input entry
Scores[count] = entry
Endfor
Stop
A) out of memory
B) no match was found
C) out of bounds
D) bounded
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck