Multiple Choice
Consider the following implementation of insertion sort:
Public static void insertionSort(int [ ] array) {
Int unsortedValue;// The first unsorted value
Int scan;// Used to scan the array
// The outer loop steps the index variable through
// each subscript in the array,starting at 1.This
// is because element 0 is considered already sorted.
For (int index = 1;index < array.length;index++) {
// The first element outside the sorted segment is
// array[index].Store the value of this element
// in unsortedValue
UnsortedValue = array[index];
// Start scan at the subscript of the first element
// outside the sorted segment.
Scan = index;
// Move the first element outside the sorted segment
// into its proper position within the sorted segment.
While (scan > 0 && array[scan-1] > unsortedValue) {
Array[scan] = array[scan - 1];
Scan --;
}
// Insert the unsorted value in its proper position
// within the sorted segment.
Array[scan] = unsortedValue;
}
}
This method uses the < and > operators to compare array subscripts,as when index is compared against the length of the array,a.length.The method also uses these operators to compare array elements against each other,for example,in an expression such as a[scan-1] >unSortedValue.What would happen if we change every < operator to >,and change every > operator to < ?
A) Instead of sorting in ascending order,the method would sort in descending order
B) The method would throw an array index out of bounds exception
C) The method would return,leaving the array unmodified
D) The method would modify the array,but the array would likely not be sorted correctly
Correct Answer:

Verified
Correct Answer:
Verified
Q3: When applied to an array a[ ]
Q4: An array a[ ] of N elements
Q5: Let F be an algorithm with complexity
Q6: The selection sort algorithm works by<br>A) repeatedly
Q7: Binary Search is in the complexity class<br>A)
Q9: The insertion sort algorithm works by<br>A) repeatedly
Q10: A search for an item X in
Q11: If lower is the first subscript in
Q12: A contigous segment of an array is
Q13: Assuming a method<br>Int findMax(int array[ ],int last)that