1) If a binary search is used to search for the number 4 in the 11-element array
ID: 655148 • Letter: 1
Question
1) If a binary search is used to search for the number 4 in the 11-element array shown below, which value will the 4 be compared to first?
1 2 3 4 5 6 7 8 9 10 11 12 17
1
7
8
9
17
2) True/false: Memory cannot be allocated after a program is already running
3) To find a value that is in an unordered array of 100 items, linear search must examine an average of ______
7
10
50
100
101
4) To locate a value that is in an ordered array of 50 items, linear search must examine at most____ values.
1
6
25
50
51
5) If a selection sort is used to arrange the number 7 5 3 9 2 6 in ascending order, what order will that data be in after the first pass?
2 5 3 9 7 6
5 7 3 9 2 6
5 3 7 2 6 9
2 3 5 6 7 9
None of these
6) The statement
typedef int oneDArray[20];
does which of the following?
Creates an array of 20 integers
Makes oneDArray a copy of another 20-integer array
Makes oneDarray an alias for a data type that holds 20 integers
Creates a one-dimensional integer array with all elements initialized to 20
None of these
Explanation / Answer
1)
The value will be compared with 7.
2)
The meory can be dynamically allocated while the program is running. The variable names cannot be created at run time So, the answer is False.
3)
The linear search depends upon number of comparisions. In general for an unordered array the number of comparisons required to search for a key value (average case) is size of array/2= 100/2=50.
4)
The linear search depends upon number of comparisions. In general for an ordered array the number of comparisons required to search for a key value (worst case) is size of array. Given, the size of the array is 50. So, the number of comparisions that are atmost required is 50.
5)
The selectin sort compares the first element with the remaining elements in array and swaps the values. Here 7 is compared with all elements of the array and after the first pass the smallest value 2 is obatined at 5th iteration.
Thus the answer is 2 5 3 9 7 6.
6)
typedef uis a keyword. It forms the complex types from basic data type. It provides a new type name.
The statement typedef int oneDArray[20]; makes a oneDarray with the datatype porvided. Her the data type is int. So, the array holds 20 elements of integer datatype. The correct answer is Makes oneDarray an alias for a data type that holds 20 integers.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.