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...

A T-3 connection provides the same number of voice channels as

a. 2 T-1 lines b. 4 T-1 lines c. 24 T-1 lines d. 28 T-1 lines

Computer Science & Information Technology

The ____ command aligns selected items using the boundaries of the page.

A. Align to Spread B. Align to Margins C. Align to Group D. Align to Page

Computer Science & Information Technology

Each separate array variable is one ____ of the array.

A. element B. aspect C. index D. member

Computer Science & Information Technology

Critical Thinking QuestionsCase 1-2Your colleague Diane wants to take advantage of Outlook's spelling and grammar-checking capabilities, and she turns to you for help. Diane notices a blue wavy underline in her email message. What does this indicate about the underlined text? a. It is not in Outlook's main dictionary.c. It may contain a contextual spelling error.b. It may be incorrect grammatically.d. It may be a proper name.

What will be an ideal response?

Computer Science & Information Technology