10-Dars. Tartiblash Algoritmlari
10-Dars. Tartiblash Algoritmlari
10-Dars. Tartiblash Algoritmlari
Reja:
• SELECTION SORT
• INSERTION SORT
• BUBBLE SORT
• Amaliy mashqlar
Tartiblash algoritmlari
SELECTION SORT
void selectionSort(int arr[], int n)
{
int i, j, min_idx;
selectionSort(arr, n);
return 0;
}
INSERTION SORT
/* Function to sort an array using insertion sort*/
void insertionSort(int arr[], int n)
{
int i, key, j;
for (i = 1; i < n; i++)
{
key = arr[i];
j = i - 1;
printArray(arr, n);
return 0;
}
BUBBLE SORT
// A function to implement bubble sort
void bubbleSort(int arr[], int n)
{
int i, j;
for (i = 0; i < n-1; i++)
bubbleSort(arr, n);
return 0;
}
Amaliy mashqlar
Butun sonlardan iborat 7 ta elementli massiv berilgan.
Massiv elementlari tasodifiy sonlar generatori yordamida
aniqlanadi.