Expt 9 Selection Sort ADA Lab
Expt 9 Selection Sort ADA Lab
9. Design and implement C/C++ Program to sort a given set of n integer elements using Selection
Sort method and compute its time complexity. Run the program for varied values of n> 5000 and
record the time taken to sort. Plot a graph of the time taken versus n. The elements can be read
from a file or can be generated using the random number generator.
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
// main function
int main() {
int n;
printf("Enter the number of elements: ");
scanf("%d", &n);
int arr[n];
Output-1:
Generated array:
Sorted array:
Output-2
Generated array:
873 67 725 144 80 459 156 36 4 130 284 929 404 759 699 775 92 27 179 679 404 839 321 43 989 419
758 369 765 151 523 990 570 601 134 651 60 642 39 64 124 323 994 528 435 693 655 527 72 834 558
828 673 879 872 14 299 630 383 416 133 907 406 56 508 892 59 568 535 98 984 659 773 978 540 208
23 195 87 447 30 645 276 55 525 500 70 176 482 453 944 616 712 702 24 572 594 83 492 129
Sorted array: