Deck 6: Arrays and Vectors
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/19
العب
ملء الشاشة (f)
Deck 6: Arrays and Vectors
1
An array is not:
A) A consecutive group of memory locations.
B) Subscripted by integers.
C) Declared using braces, [].
D) Made up of different data types.
A) A consecutive group of memory locations.
B) Subscripted by integers.
C) Declared using braces, [].
D) Made up of different data types.
D
2
Which of the following does not declare a 2-by-2 array and set all four of its elements to 0?
A) int b [ 2 ][ 2 ]; b[ 0 ][ 0 ] = b[ 0 ][ 1 ] = b[ 1 ][ 0] = b[ 1 ][ 1 ] = 0;
B) int b[ 2 ][ 2 ] = { 0 };
C) int b[ 2 ][ 2 ]; for int i = 0; i < 2; i++ )
For int j = 0; j < 2; j++ )
B[ i ][ j ] = 0;
D) All of the above initialize all four of the array elements to 0.
A) int b [ 2 ][ 2 ]; b[ 0 ][ 0 ] = b[ 0 ][ 1 ] = b[ 1 ][ 0] = b[ 1 ][ 1 ] = 0;
B) int b[ 2 ][ 2 ] = { 0 };
C) int b[ 2 ][ 2 ]; for int i = 0; i < 2; i++ )
For int j = 0; j < 2; j++ )
B[ i ][ j ] = 0;
D) All of the above initialize all four of the array elements to 0.
D
3
Which statement about insertion sort is true?
A) A maximum of n comparisons are needed to sort the array, where n is the number of elements.
B) The algorithm is simple compared to other sorting procedures.
C) No temporary variables are needed.
D) Performance is maximized.
A) A maximum of n comparisons are needed to sort the array, where n is the number of elements.
B) The algorithm is simple compared to other sorting procedures.
C) No temporary variables are needed.
D) Performance is maximized.
B
4
To prevent modification of array values passed to a function:
A) The array must be declared static in the function.
B) The array parameter can be preceded by the const qualifier.
C) A copy of the array must be made inside the function.
D) The array must be passed by reference.
A) The array must be declared static in the function.
B) The array parameter can be preceded by the const qualifier.
C) A copy of the array must be made inside the function.
D) The array must be passed by reference.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 19 في هذه المجموعة.
فتح الحزمة
k this deck
5
Unless otherwise specified, entire arrays are passed __________ and individual array elements are passed __________.
A) By value, by reference.
B) By reference, by value.
C) By value, by value.
D) By reference, by reference.
A) By value, by reference.
B) By reference, by value.
C) By value, by value.
D) By reference, by reference.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 19 في هذه المجموعة.
فتح الحزمة
k this deck
6
Linear search can be used on:
A) Unsorted arrays.
B) Sorted arrays.
C) Integer arrays.
D) Any of the above.
A) Unsorted arrays.
B) Sorted arrays.
C) Integer arrays.
D) Any of the above.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 19 في هذه المجموعة.
فتح الحزمة
k this deck
7
Which of the following is not a correct way to initialize an array?
A) int n[ 5 ] = { 0, 7, 0, 3, 8, 2 };
B) int n[] = { 0, 7, 0, 3, 8, 2 };
C) int n[ 5 ] = { 7 };
D) int n[ 5 ] = { 9, 1, 9 };
A) int n[ 5 ] = { 0, 7, 0, 3, 8, 2 };
B) int n[] = { 0, 7, 0, 3, 8, 2 };
C) int n[ 5 ] = { 7 };
D) int n[ 5 ] = { 9, 1, 9 };
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 19 في هذه المجموعة.
فتح الحزمة
k this deck
8
Which of the following is not true of class template vector?
A) The size of a vector can be changed after it is declared.
B) A vector can be assigned to another vector by using the assignment operator.
C) A vector object can be initialized with a copy of another vector.
D) A vector can store only data of type int.
A) The size of a vector can be changed after it is declared.
B) A vector can be assigned to another vector by using the assignment operator.
C) A vector object can be initialized with a copy of another vector.
D) A vector can store only data of type int.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 19 في هذه المجموعة.
فتح الحزمة
k this deck
9
In a typical nested for-loop used to process a two-dimensional array, following the end of the each execution of the inner for loop:
A) The outer for loop initializes its counter variable.
B) The outer for loop increments its counter variable.
C) The inner for loop initializes its counter variable.
D) The inner for loop increments its counter variable.
A) The outer for loop initializes its counter variable.
B) The outer for loop increments its counter variable.
C) The inner for loop initializes its counter variable.
D) The inner for loop increments its counter variable.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 19 في هذه المجموعة.
فتح الحزمة
k this deck
10
Linear search is highly inefficient compared to binary search when dealing with:
A) Small, unsorted arrays.
B) Small, sorted arrays.
C) Large, unsorted arrays.
D) Large, sorted arrays.
A) Small, unsorted arrays.
B) Small, sorted arrays.
C) Large, unsorted arrays.
D) Large, sorted arrays.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 19 في هذه المجموعة.
فتح الحزمة
k this deck
11
Which statement would be used to declare a 10-element integer array c?
A) array c = int[ 10 ];
B) c = int[ 10 ];
C) int array c[ 10 ];
D) int c[ 10 ];
A) array c = int[ 10 ];
B) c = int[ 10 ];
C) int array c[ 10 ];
D) int c[ 10 ];
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 19 في هذه المجموعة.
فتح الحزمة
k this deck
12
Which of the following is false?
A) The last element of an array has position number one less than the array size.
B) The position number contained within square brackets is called a subscript.
C) A subscript cannot be an expression.
D) All of the above.
A) The last element of an array has position number one less than the array size.
B) The position number contained within square brackets is called a subscript.
C) A subscript cannot be an expression.
D) All of the above.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 19 في هذه المجموعة.
فتح الحزمة
k this deck
13
Which of the following statements is false about a function to which an array is being passed?
A) It always knows the size of the array that is being passed.
B) It is being passed the address of the first element in the array.
C) It is able to modify the values stored in the array.
D) The array name is used as an argument in the function call.
A) It always knows the size of the array that is being passed.
B) It is being passed the address of the first element in the array.
C) It is able to modify the values stored in the array.
D) The array name is used as an argument in the function call.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 19 في هذه المجموعة.
فتح الحزمة
k this deck
14
After the ith iteration of the insertion sort:
A) The ith element of the array is in its final position.
B) The ith element of the array is currently empty.
C) The first i elements of the array are sorted.
D) The last i elements of the array are sorted.
A) The ith element of the array is in its final position.
B) The ith element of the array is currently empty.
C) The first i elements of the array are sorted.
D) The last i elements of the array are sorted.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 19 في هذه المجموعة.
فتح الحزمة
k this deck
15
Constant variables:
A) Can be assigned values in executable statements.
B) Do not have to be initialized when they are declared.
C) Can be used to specify array sizes, thereby making programs more scalable.
D) Can be used to specify array sizes, but this makes programs harder to understand.
A) Can be assigned values in executable statements.
B) Do not have to be initialized when they are declared.
C) Can be used to specify array sizes, thereby making programs more scalable.
D) Can be used to specify array sizes, but this makes programs harder to understand.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 19 في هذه المجموعة.
فتح الحزمة
k this deck
16
A double subscripted array declared as int a[ 3 ][ 5 ]; has how many elements?
A) 15
B) 13
C) 10
D) 8
A) 15
B) 13
C) 10
D) 8
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 19 في هذه المجموعة.
فتح الحزمة
k this deck
17
Referencing elements outside the array bounds:
A) Can result in changes to the value of an unrelated variable.
B) Is impossible because C++ checks to make sure it does not happen.
C) Is a syntax error.
D) Enlarges the size of the array.
A) Can result in changes to the value of an unrelated variable.
B) Is impossible because C++ checks to make sure it does not happen.
C) Is a syntax error.
D) Enlarges the size of the array.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 19 في هذه المجموعة.
فتح الحزمة
k this deck
18
Using square brackets []) to retrieve vector elements __________ perform bounds checking; using member function at to retrieve vector elements __________ perform bounds checking.
A) Does not, does not.
B) Does not, does.
C) Does, does not.
D) Does, does.
A) Does not, does not.
B) Does not, does.
C) Does, does not.
D) Does, does.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 19 في هذه المجموعة.
فتح الحزمة
k this deck
19
Given the following declaration, what is the value of b[ 1 ][ 0 ]?
Int b[ 2 ][ 2 ] = { { 1 }, { 3 , 4 } };
A) 0
B) 1
C) 3
D) This is not a valid declaration.
Int b[ 2 ][ 2 ] = { { 1 }, { 3 , 4 } };
A) 0
B) 1
C) 3
D) This is not a valid declaration.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 19 في هذه المجموعة.
فتح الحزمة
k this deck