write a program to sort 'n' elemnts using bubble sort
Answer Posted / jony
hi, This is a program in java programming language to sort
an array of elements using bubble sort technique.......
public class bubbleSort{
public static void main(String a[]){
int i;
int array[] = {12,9,4,99,120,1,3,10};
System.out.println("Values Before the sort:");
for(i = 0; i < array.length; i++)
System.out.print( array[i]+" ");
System.out.println();
bubble_srt(array, array.length);
System.out.print("Values after the sort:");
for(i = 0; i <array.length; i++)
System.out.print(array[i]+" ");
}
public static void bubble_srt( int a[], int n ){
int i, j,t=0;
for(i = 0; i < n; i++){
for(j = 1; j < (n-i); j++){
if(a[j-1] > a[j]){
t = a[j-1];
a[j-1]=a[j];
a[j]=t;
}
}
}
}
}
| Is This Answer Correct ? | 12 Yes | 1 No |
Post New Answer View All Answers
develop a program to calculate and print body mass index for 200 employees
Write a C/C++ program that connects to a MySQL server and displays the global TIMEZONE.
how to write a program that opens a file and display in reverse order?
write a program to convert temperature from fa height into celcius and vise versa,use modular programming
We need to write the function to check the password entered is correct or not based on the following conditions.. a) It must have atleast one lower case character and one digit. b)It must not have any Upper case characters and any special characters c) length should be b/w 5-12. d) It should not have any same immediate patterns like abcanan1 : not acceptable coz of an an pattern abc11se: not acceptable, coz of pattern 11 123sd123 : acceptable, as not immediate pattern adfasdsdf : not acceptable, as no digits Aasdfasd12: not acceptable, as have uppercase character
write a program to perform generic sort in arrays?
write a program that reads a series of strings and prints only those strings begging with letter "b"
write a function that allocates memory for a single data type passed as a parameter.the function uses the new operator and return a pointer to the allocated memory.the function must catch and handle any exception during allocation
write a program that creates a sequenced array of numbers starting with 1 and alternately add 1 and then 2 to create the text number in the series , as shown below. 1,33,4,6,7,9,............147,148,150 Then , using a binary search , searches the array 100 times using randomly generated targets in the range of 1 to 150
How to Split Strings with Regex in Managed C++ Applications?
write a program using 2 D that searches a number and display the number of items 12 inputs values input 15,20, 13, 30, 38, 40,16, 18, 20 ,18 ,20 enter no. to search : 20
Write a (n) algorithm that sorts n distinct integers, ranging in size between 1 and kn inclusive, where k is a constant positive integer. (Hint: Use a kn-element array.)
Write a simple encryption program using string function which apply the substitution method.
How can I Draw an ellipse in 3d space and color it by using graph3d?
write a program using virtual function to find the transposing of a square matrix?