Bubble Sort With Flag

  • Uploaded by: sefrinaldi
  • 0
  • 0
  • April 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Bubble Sort With Flag as PDF for free.

More details

  • Words: 465
  • Pages: 2
Nama Kelas No. BP

: RISMANTO : IF-6 : 07101152630389

public class BubbleSortWithFlag{ public static void main(String[]args){ int Flag=0; int Swap=0; int Buffer=0; int n=7; int Data []={0,8,9,1,2,4,5,3}; do{ Swap=0; Flag=Flag+1; //Tampilan Saja System.out.println(" Flag "+Flag); //Akhir Tampilan Saja for(int J=1;J<=n-Flag;J++){ if(Data [J] > Data [J+1]){ Buffer=Data[J]; Data[J]=Data[J+1]; Data[J+1]=Buffer; Swap=1; } for (int A=0;A<=n;A++){ System.out.print("Data ="+Data[A]+" ");

}

} System.out.println("Buffer ="+Buffer+"Swap ="+Swap);

}while (Swap >0); }

}

========================================================= Hasil dari proses init: deps-jar: compile-single: run-single: Flag 1 Data =0 Data =8 Data =0 Data =8 Data =0 Data =8 Data =0 Data =8 Data =0 Data =8 Data =0 Data =8 Flag 2 Data =0 Data =1 Data =0 Data =1 Data =0 Data =1

Data Data Data Data Data Data

=9 =1 =1 =1 =1 =1

Data Data Data Data Data Data

=1 =9 =2 =2 =2 =2

Data Data Data Data Data Data

=2 =2 =9 =4 =4 =4

Data Data Data Data Data Data

=4 =4 =4 =9 =5 =5

Data Data Data Data Data Data

=5 =5 =5 =5 =9 =3

Data Data Data Data Data Data

=3 =3 =3 =3 =3 =9

Buffer Buffer Buffer Buffer Buffer Buffer

=0Swap =9Swap =9Swap =9Swap =9Swap =9Swap

=0 =1 =1 =1 =1 =1

Data =8 Data =2 Data =4 Data =5 Data =3 Data =9 Buffer =8Swap =1 Data =2 Data =8 Data =4 Data =5 Data =3 Data =9 Buffer =8Swap =1 Data =2 Data =4 Data =8 Data =5 Data =3 Data =9 Buffer =8Swap =1

Data =0 Data =0 Flag 3 Data =0 Data =0 Data =0 Data =0 Flag 4 Data =0 Data =0 Data =0 Flag 5 Data =0 Data =0

Data =1 Data =2 Data =4 Data =5 Data =8 Data =3 Data =9 Buffer =8Swap =1 Data =1 Data =2 Data =4 Data =5 Data =3 Data =8 Data =9 Buffer =8Swap =1 Data Data Data Data

=1 =1 =1 =1

Data Data Data Data

=2 =2 =2 =2

Data Data Data Data

=4 =4 =4 =4

Data Data Data Data

=5 =5 =5 =3

Data Data Data Data

=3 =3 =3 =5

Data Data Data Data

=8 =8 =8 =8

Data Data Data Data

=9 =9 =9 =9

Buffer Buffer Buffer Buffer

=8Swap =8Swap =8Swap =5Swap

=0 =0 =0 =1

Data =1 Data =2 Data =4 Data =3 Data =5 Data =8 Data =9 Buffer =5Swap =0 Data =1 Data =2 Data =4 Data =3 Data =5 Data =8 Data =9 Buffer =5Swap =0 Data =1 Data =2 Data =3 Data =4 Data =5 Data =8 Data =9 Buffer =4Swap =1 Data =1 Data =2 Data =3 Data =4 Data =5 Data =8 Data =9 Buffer =4Swap =0 Data =1 Data =2 Data =3 Data =4 Data =5 Data =8 Data =9 Buffer =4Swap =0

Related Documents

Bubble Sort With Flag
April 2020 16
Bubble Sort
May 2020 17
Bubble Sort
May 2020 22
Bubble Sort
June 2020 8
Parallel Bubble Sort
May 2020 18

More Documents from "Wayan Sriyasa"

Bubble Sort With Flag
April 2020 16