Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Sorting It is often necessary to sort data. The following piece of code sorts the contents of an integer array called items. int items[10] =

Sorting

It is often necessary to sort data. The following piece of code sorts the contents of an integer array called items.

int items[10] = {1,6,9,5,4,2,8,0,7,3};

void sort()

{

int i;

int j;

int temp;

for (i=0; i<9; i++)

{

for (j=i+1; j<10; j++)

{

if (items[i] > items[j])

{

temp = items[i];

items[i] = items[j];

items[j] = temp;

}

}

}

}

  1. What numbers will be exchanged on the first swap to sort the array?
  1. 1 and 0
  2. 2 and 3
  3. 5 and 6
  4. 4 and 2

  1. What numbers will be exchanged on the second swap to sort the array?
  1. 8 and 7
  2. 5 and 4
  3. 9 and 6
  4. 6 and 5

  1. What numbers will be exchanged on the third swap to sort the array?
  1. 3 and 2
  2. 7 and 0
  3. 5 and 4
  4. 9 and 5

  1. What numbers will be exchanged on the fourth swap to sort the array?
  1. 7 and 0
  2. 5 and 4
  3. 4 and 2
  4. 6 and 3

  1. What numbers will be exchanged on the fifth swap to sort the array?
  1. 2 and 1
  2. 5 and 4
  3. 8 and 3
  4. 6 and 2

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Describe the economic model that is proposed for the operation.

Answered: 1 week ago