Earn in Dollars

PaidVerts

Assignment No. 01
Semester: Fall 2015
CS502: Fundamentals of Algorithms

Total Marks: 20

Due Date:25/11/2015

Instructions
Please read the following instructions carefully before submitting assignment:
It should be clear that your assignment will not get any credit if:
  • The assignment is submitted after due date.
  • The submitted assignment does not open or file is corrupt.
  • Solution is copied from any other source.
Objective
The objective of this assignment is to;
  • Learn and practice Algorithm running time analysis
Assignment

In this assignment, you are provided with sample code of two sorting algorithmsInsertion_sort.cpp and Quick_sort.cpp. The code is self explanatory. Inside both programs, we define an array of size ‘n’ and fill it with random values generated by some seed value. Afterwards, we apply sorting algorithm to sort the array elements. You can find in code that we record the system time before and after sorting operation in order to get the total time taken.
Your Task
You are required to execute the given programs in Dev-C++ and get the running time for various array sizes and seed values. You shall record your results in the excel sheet Results.xls provided along with this assignment. You need to get running time for array size of 10000, 30000…50,000 for both Insertion and Quick sort programs and report your values in given excel file by replacing the zero values in table for Experimental results accordingly. You shall also mention the seed value you use for these results.
After performing all experiments, you need to make a graph (visual representation) for each algorithm to see its growth in running time w.r.t. input size of array as shown for theoretical results. You also need to discuss the results graph in your own words.

Submission
You are required to submit your solution through LMS as MS Excel document which contain your calculated running time and discussion on results as desired.

SOLUTION

First understand seed:
Hint! The "seed" is a starting point for the sequence
If you need just a random sequence of numbers and don't need to reproduce it then just use current time as seed... for example with:
srand(time(NULL));
Then run both programs of *.cpp files and note the reading and put in the respective rows as per the Arrays.
The result graph will be developed same as experimental graph


 
Top