EXP 11-Sorting
EXP 11-Sorting
Grade: AA / AB / BB / BC / CC / CD /DD
CO Outcome
Example:
Take any random unsorted sequence of numbers and solve by using the Bubble and
Shell Sort. Clearly showcase the sorted array after every pass.
The above is a pen-paper activity, take a picture of the solution and put it here.
Program:
1)Bubble Sort:
#include <stdio.h>
arr[j + 1] = temp;
printf("\n");
int main() {
int n;
scanf("%d", &n);
scanf("%d", &arr[i]);
printArray(arr, n);
bubbleSort(arr, n);
printArray(arr, n);
return 0;
2)Shell Sort:
#include <stdio.h>
int j;
arr[j] = temp;
printf("\n");
int main() {
int n;
scanf("%d", &n);
scanf("%d", &arr[i]);
printArray(arr, n);
shellSort(arr, n);
printArray(arr, n);
return 0;
Output screenshots:
1)Bubble Sort:
2)Shell Sort:
Conclusion:-
1) Describe how shell sort improves upon bubble sort. What are the main differences
in their approaches?
2) Explain the significance of the gap in shell sort. How does changing the gap
sequence affect the performance of the algorithm?
3) In what scenarios would you choose shell sort over bubble sort? Discuss the types
of datasets where shell sort performs better.