Computer Science, asked by kohirmanideep2468, 2 months ago


Given an array, arr(0, 2,3,5, 4], and an integer x = 1, sort the array using the method below.
Each operation is: Choose a number i such that arr[i] > x. Swap the values of a[i] and x.
What is the minimum number of operations required to sort the array in ascending order?

Answers

Answered by nancychaterjeestar29
16

Answer:

SORTED ARRAY [0,1,2,3,4,5]

Explanation:

Here in this question we are supposed to sort an array in decreasing order so here we use bubble sort which comes with the technique of swapping. for i=1 to i=n-1

if a[i]>x then

swap

this is the algorithm used for bubble sort.

#SPJ3

Similar questions