How many comparisons of array items do the following loops contain?

```
for (j = 1; j <= n-1; j++)
{
i = j + 1;
do
{
if (theArray[i] < theArray[j])
swap(theArray[i], theArray[j]);
i++;
} while (i <= n);
}

```

(n– 1) + (n– 2) +...+ 1 = nx (n– 1)/2

Computer Science & Information Technology

You might also like to view...

The two background elements of an Excel chart are:

A) plot area and chart area. B) fill and line. C) legend and axis. D) error bars and gridlines.

Computer Science & Information Technology

In a two-sided tag, a(n) ____ tag indicates the content's end.

A. end B. closing C. empty D. exit

Computer Science & Information Technology