CGI Interview Question

write bubble sort and find completely

Interview Answers

Anonymous

Dec 6, 2015

easiest question.

Anonymous

Mar 23, 2016

public class BubbleSort { public static void main(String[] args) { // TODO Auto-generated method stub int arr[] = new int[]{2,4,1,6,7,4,9,24,3,2,1}; System.out.println("Unsorted array"); for(int j:arr){ System.out.print(" "+j); } int temp; for(int i=0;iarr[j]){ temp=arr[j]; arr[j]=arr[i]; arr[i]=temp; } } } System.out.println("\nsorted array"); for(int j:arr){ System.out.print(" "+j); } } }