CS111-Programming Project 1 2025
CS111-Programming Project 1 2025
This project involves conducting an empirical analysis of six sorting algorithms—Selection Sort, Bubble Sort,
Insertion Sort, Mergesort, Quicksort, and Heapsort—by sorting randomly generated integers and evaluating their
performance.
Project Requirements
A. Desired Program Behavior
1. User Input
• The program prompts the user to enter a value N (number of integers to be sorted).
• The user selects one of two data generation methods:
a) Randomly Generated Integers
• The program generates N integers uniformly at random from the range [0,
MAX_RANGE] (MAX_RANGE is an unsigned long int constant).
b) Increasing Sequence
• The program prompts the user to enter a starting value X (a positive number).
• It generates an increasing sequence where:
• The first element is X,
• The second element is X+1,
• The third element is X+2, and so on, for N elements.
2. Sorting and Output
• The program sorts the generated integers using all six sorting algorithms. Each sorting
algorithms should be implemented as functions not as individual programs.
• It writes both the original and sorted values to an output file.
3. Performance Measurement
• The program measures and outputs the computation time for sorting N integers for each
algorithm.
• Computation time should exclude user interaction, number generation, and file I/O.
• The clock() function from <time.h> should be used to measure execution time:
#include <time.h>
start = clock();
// Sorting operation
end = clock();
cpu_time_used = ((double) (end-start)) / CLOCKS_PER_SEC;
3. Graphical Representation:
• The final results should be presented in both table and graphical formats.
• The rows in the table represent different values of N, while the columns represent the average
execution times for each sorting algorithm.
• A graph should plot N on the x-axis and the average execution time on the y-axis, with different
lines representing different sorting algorithms.
Table Format:
Average Running Time for an Input Array that is Random
N Selection Bubble Sort Insertion sort Mergesort Quicksort Heapsort
Sort
10
100
1000
10000
100000
1000000
Note: Submissions consisting solely of source code will not be accepted. A program demonstration and defense
are required.