instanceof java
Posts: 576
Nickname: instanceof
Registered: Jan, 2015
|
instanceof java is a java related one.
|
|
|
|
Bubble sort algorithm in java with example
|
Posted: Dec 28, 2015 6:42 AM
|
|
|
This post originated from an RSS feed registered with Java Buzz
by instanceof java.
|
Original Post: Bubble sort algorithm in java with example
Feed Title: Instance Of Java
Feed URL: http://feeds.feedburner.com/blogspot/TXghwE
Feed Description: Instance of Java. A place where you can learn java in simple way each and every topic covered with many points and sample programs.
|
Latest Java Buzz Posts
Latest Java Buzz Posts by instanceof java
Latest Posts From Instance Of Java
|
|
Java Program to sort array using bubble sort- package com.instaceofjava;
- public class BubbleSortExample{
-
- int[] array={4,2,5,6,9,1};
-
- int n = array.length;
- int k;
-
- for (int m = n; m>= 0; m--) {
-
- for (int j = 0; j < n-1; j++) {
-
- k = j + 1;
-
- if (array[j] > array[k]) {
-
- int temp;
- temp = array[j];
- array[j] = array[k];
- array[k] = temp;
-
- }
- }
-
- for (int x = 0; x < array.length; x++) {
-
- System.out.print(array[x] + ", ");
-
- }
-
- System.out.println();
- }
-
- }
-
- }
Output: - 2, 4, 5, 6, 1, 9,
- 2, 4, 5, 1, 6, 9,
- 2, 4, 1, 5, 6, 9,
- 2, 1, 4, 5, 6, 9,
- 1, 2, 4, 5, 6, 9,
- 1, 2, 4, 5, 6, 9,
- 1, 2, 4, 5, 6, 9,
Read: Bubble sort algorithm in java with example
|
|