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

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;
}
}

```

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


C) The method would return, leaving the array unmodified

Computer Science & Information Technology

You might also like to view...

Case-based Critical Thinking QuestionsCase 13-2Judy has begun to apply the basic information that you have given her about schemas, and she would now like your help in mastering the details of how schemas work. In her definition of the recipe element, Judy would like to reference the existing definition of the ingredient element. Which of the following element declarations accomplishes this?

A. B. C. D.

Computer Science & Information Technology

Which of the following statements are true?

a. java.util.List inherits all the methods from java.util.Collection. Additionally, it contains new methods for manipulating a list. b. The AbstractList class provides a partial implementation for the List interface. c. ArrayList is a concrete implementation of List using an array. d. LinkedList is a concrete implementation of List using a linked list. LinkedList contains all the methods in List and additional new methods for manipulating a linked list. e. ListIterator is a subinterface of Iterator and it provides the methods to support bi-directional traversal of a list.

Computer Science & Information Technology

The accompanying diagram is known as a ____.

A. hierarchy chart B. truth table C. decision table D. flowchart

Computer Science & Information Technology

Nonmodifying algorithms do not modify the elements of the container.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology