DAA Week - 3 - SS
DAA Week - 3 - SS
Aim: Sort a given set of elements using Selection sort and determine the time required to sort
elements. Repeat the experiment for different values of n, the number of elements in the list
to be sorted and plot a graph of the time taken versus n.
Definition: selection sort is a sorting routine that scans a list of items repeatedly and, on each
pass, selects the item with the lowest value and places it in its final position. It is based on
brute force approach. Sequential search is a Θ(n2) algorithm on all inputs.
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int arr[n];
srand(time(NULL)); // Seed for random number generation
return 0;
}
Output:
Note down the different values of n(eg: 5000,6000,7000,8000,9000,10000) and required
time for all values of n respectively. Plot the graph for the same.