Wipro Coding Question 2

Bubble Sort

 

Here, in this page we will discuss the Wipro coding question asked in previous recruitment drive. We will  write an efficient algorithm for bubble sort and there solution in C++ and Java. 

Merge two sorted array in C

Question 2

Write a program to implement a bubble sort algorithm for sorting the elements of an array. We are given with a array of N elements and we need to sort them in ascending order. But in this question we need to use Bubble sort, to sort the given array.

Input Format:

  • The first line corresponds to the size of an array.
  • The second line corresponds to the elements.

Output Format:

Print the N elements of the array in ascending order.

Sample Input:

6

11 15 26 38 9 10 

Sample Output:

9 10 11 15 26 38

Explanation :

Here, we have 6 elements and array elements are 11 15 26 38 9 10, Sorted array in ascending order will be 9 10 11 15 26 38.