


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
Tugas Programing membuat aplikasi sort
Typology: Study notes
1 / 4
This page cannot be seen from the preview
Don't miss anything!
package sorting2; import java.util.Random; import java.util.Scanner; public class Buble { static Random random = new Random(); static Scanner in = new Scanner(System.in); public static void main(String[] args) { int array[] = new int[10000]; for (int i = 0; i < array.length; i++) { array[i] = CreateArray(); } BubleSort(array); } public static int CreateArray() { return (random.nextInt(10000)) ; } public static void tampil(int a[]) { for (int i = 0; i < a.length; i++) { System.out.print(a[i] + " "); } System.out.println(" "); System.out.println(); } public static void BubleSort(int a[]) { int flag = 0; int temp = 0; for (int i = 0; i < a.length; i++) { for (int j = 0; j < 10000; j++) { if (a[i] <= a[j]){ Swap(a, temp, i, j); } } tampil(a); } } public static void Swap(int a[], int temp, int i, int j) { temp = a[i]; a[i] = a[j]; a[j] = temp; } }
package sorting2; import java.util.Random; import java.util.Scanner; public class Insertion {