Exam 8: Searching and Sorting Arrays
Exam 1: Introduction to Computers and Programming47 Questions
Exam 2: Introduction to C62 Questions
Exam 3: Expressions and Interactivity45 Questions
Exam 4: Making Decisions51 Questions
Exam 5: Loops and Files60 Questions
Exam 6: Functions49 Questions
Exam 7: Arrays and Vectors56 Questions
Exam 8: Searching and Sorting Arrays30 Questions
Exam 9: Pointers47 Questions
Exam 10: Characters, C-Strings, and More About the String Class47 Questions
Exam 11: Structured Data46 Questions
Exam 12: Advanced File Operations38 Questions
Exam 13: Introduction to Classes54 Questions
Exam 14: More About Classes46 Questions
Exam 15: Inheritance, Polymorphism, and Virtual Functions43 Questions
Exam 16: Exceptions and Templates36 Questions
Exam 17: The Standard Template Library38 Questions
Exam 18: Linked Lists41 Questions
Exam 19: Stacks and Queues47 Questions
Exam 20: Recursion27 Questions
Exam 21: Binary Trees39 Questions
Select questions type
Before you can perform a selection sort, the data must be stored in ascending order.
Free
(True/False)
4.9/5
(37)
Correct Answer:
False
The following is the pseudocode for which type of algorithm?
Set first to 0
Set last to the last subscript in the array
Set found to False
Set position to -1
While found is not true and first is less than or equal to last
Set middle to the subscript halfway between array[first] and array[last]
If array[middle] equals the desired value
Set found to true
Set position to middle
Else If array[middle] is greater than the desired value
Set last to middle - 1
Else
Set first to middle + 1
End If
End While
Return position
Free
(Multiple Choice)
4.8/5
(43)
Correct Answer:
C
Array elements must __________ before a binary search can be performed.
Free
(Multiple Choice)
4.9/5
(39)
Correct Answer:
D
The number of comparisons made by a binary search is expressed in powers of two.
(True/False)
4.8/5
(34)
On average, an item is just as likely to be found near the beginning of an array as near the end.
(True/False)
4.8/5
(32)
The __________ sort usually performs fewer exchanges than the __________ sort.
(Multiple Choice)
4.8/5
(44)
A __________ algorithm is a method of locating a specific item of information in a larger collection of data.
(Multiple Choice)
4.8/5
(44)
Assume you have two integer variables, num1 and num2. Which of the following is the correct way to swap the values in these two variables?
(Multiple Choice)
4.7/5
(34)
When an array is sorted from highest to lowest, it is said to be in
(Multiple Choice)
4.8/5
(28)
Before you can perform a bubble sort, the data must be stored in descending order.
(True/False)
4.9/5
(40)
A(n) __________ search uses a loop to sequentially step through an array.
(Multiple Choice)
4.8/5
(30)
A __________ search is more efficient than a __________ search.
(Multiple Choice)
4.7/5
(36)
The following function should swap the values contained in two integer variables, num1 and num2. What, if anything, is wrong with this function?
Void swap(int num1, int num2)
{
Int temp = num2;
Num2 = num1;
Num1 = temp;
}
(Multiple Choice)
4.8/5
(39)
The following is the pseudocode for which type of algorithm?
For start = each array subscript, from the first to the next-to-last
MinIndex = start
MinValue = array[start]
For index = start + 1 To size - 1
If array[index] < minValue
MinValue = array[index]
MinIndex = index
End If
End For
Swap array[minIndex] with array[start]
End For
(Multiple Choice)
4.8/5
(27)
Algorithms used to arrange random data in some order are __________ algorithms.
(Multiple Choice)
4.9/5
(33)
The bubble sort is an easy way to arrange data in ascending order but it cannot arrange data in descending order.
(True/False)
4.7/5
(23)
The following is the pseudocode for which type of algorithm?
For maxElement = each subscript in the array, from the last to the first
For index = 0 To maxElement - 1
If array[index] > array[index + 1]
Swap array[index] with array[index + 1]
End If
End For
End For
(Multiple Choice)
4.8/5
(26)
The __________ is adequate for searching through small arrays.
(Multiple Choice)
4.9/5
(25)
Showing 1 - 20 of 30
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)