In the nested for loop, lines 8-11, j will not increment to the point where any elements will be written in beyond the last element of array A, because:

```
1 COUNTING-SORT( A )
2 make an Array C of length k + 1
3 for each i, from 0 to k
4 C[ i ] = 0
5 for each j, from 0 to the length of A - 1
6 C[ A[ j ] ]++
7 j = 0
8 for each i from 0 to k
9 for each m from 1 to C[ i ]
10 A[ j ] = i
11 j++
```
A. C[i] will be 0 much of the time, so lines 10-11 will be seldom executed
B. k will not be that large, or we wouldn’t be using counting sort
C. All the C[i], from i = 0 to i = k, when added together, will give the total number of elements in array A
D. j won’t be incremented beyond m, which is much smaller than the index of the last element of A

C

Computer Science & Information Technology

You might also like to view...

A control is any graphical object on a form or a report that is used to display data, perform an action, or make a form or report easier to read

Indicate whether the statement is true or false

Computer Science & Information Technology

Match the following terms to their meanings:

I. Field List II. Property Sheet III. Bound control IV. Text box control V. Hyperlink A. Displays the settings that define the characteristics of the control B. Displays the fields of the form's underlying table or query C. The most frequently used control D. A control whose source of data is a field in a table or query E. Can be added to a report in Design view

Computer Science & Information Technology