Practical No:1: Implementation of Different Sorting Techniques. 1) Write A Program To Implement Bubble Sort Program
Practical No:1: Implementation of Different Sorting Techniques. 1) Write A Program To Implement Bubble Sort Program
Roll no:29
Practical No:1
int main()
{
int arr[] = { 91, 44, 53, 63, 43, 12, 58 };
int n = sizeof(arr)/sizeof(arr[0]);
bubbleSort(arr, n);
cout<<"Sorted array: \n";
printArray(arr, n);
return 0;
}
OUTPUT:
DS Practical
Roll no:29
insertionSort(arr, n);
printArray(arr, n);
return 0;
DS Practical
Roll no:29
OUTPUT:
DS Practical
Roll no:29
return 0;
}
OUTPUT:
DS Practical
Roll no:29
int main()
{
int arr[] = {1, 4, 77, 2, 3}, i;
int n = sizeof(arr)/sizeof(arr[0]);
shellSort(arr, n);
return 0;
}
OUTPUT:
DS Practical
Roll no:29
// Count the number of times each digit occurred at (exp)th place in every
input.
for (i = 0; i < n; i++)
count[(arr[i] / exp) % 10]++;
// Inserting values according to the digit '(arr[i] / exp) % 10' fetched into
count[(arr[i] / exp) % 10].
for (i = n - 1; i >= 0; i--)
{
output[count[(arr[i] / exp) % 10] - 1] = arr[i];
count[(arr[i] / exp) % 10]--;
DS Practical
Roll no:29
int main()
{
int n, i;
cout<<"\nEnter the number of data element to be sorted: ";
cin>>n;
int arr[n];
for(i = 0; i < n; i++)
{
cout<<"Enter element "<<i+1<<": ";
cin>>arr[i];
}
radixsort(arr, n);
OUTPUT: