Guruh talabasi Abduvohid Ergashev 9-variant QuickSort 4200 elementli massiv
Download 43.9 Kb.
|
quicksort
314-18 guruh talabasi Abduvohid Ergashev 9-variant QuickSort 4200 elementli massiv Dastur kodi: package saralash; import java.util.Random; public class quickMain { public static void main(String[] args) { quickSort quickSort = new quickSort(); Random rand = new Random(); int [] arr = new int[4200]; for(int i=0; i<4200; i++){ arr[i] = rand.nextInt(1000); } System.out.println("Tasodifiy sonlardan tanlangan massiv : "); printArray(arr); quickSort.sort(arr, 0, arr.length-1); System.out.println("Saralangan massiv: "); printArray(arr); } static void printArray(int arr[]) { int n = arr.length; for (int i=0; i System.out.println(); } } package saralash; public class quickSort {
int temp = arr[i + 1]; arr[i + 1] = arr[high]; arr[high] = temp; return i + 1; } void sort(int arr[], int low, int high) { if (low < high) { int pi = partition(arr, low, high); sort(arr, low, pi - 1); sort(arr, pi + 1, high); } } } Dastur natijasi: Download 43.9 Kb. Do'stlaringiz bilan baham: |
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling