Computer Science, asked by Mrlspn6613, 1 year ago

You want to sort the following list using the bubble sort algorithm [14,33,27,35,10]. What would be the result of the operation?
A. [5,7,13,15,17]
B. [35,33,27,14,10]
C. [10,14,27,33,35]
D. [14,10,33,35,27]
E. The array cannot be sorted using the bubble sort algorithm

Answers

Answered by dnyanesh99
1
b ( 10,14,27,33,35) is the answer
Answered by franktheruler
3

Answer:

according to the question option c ( 10, 14, 27, 33, 35 ) is the correct answer.

Explanation:

 #include <stdio.h>

#define SIZE 5

int main ()

{

  int data[ SIZE ] = { 14, 33, 27, 35, 10 };

  int p, i, temp ;

  //printing data items

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

  {

     printf ("%d", data [ i ]);

  }

  //bubble sort

  for (pass = 1; pass < SIZE; ++ p ) // loop

  {

     for (i = 0; i < SIZE - 1; ++ i )

     {

        //comparing successive elements and swapping

        if (data [ i ]  >  data [ i + 1 ] )

        {

           temp = data [ i ];

           data [ i ] = data [ i + 1 ];

           data [ i + 1 ] = temp;

        }

     }

  }

  printf ("\n Data items in ascending order:\n " );

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

  {

     printf (" % d", data[ i ]);

  }

  return 0;

}

output:

10, 14, 27, 35, 10

Similar questions