Sorting algorithms are an important part of managing data. There are many sorting algorithms. Each algorithm has particular strengths and weaknesses.

You are asked to write two programs in C++, one for Insertion Sort and another for Merge Sort.

Compare the execution time for both programs for different data sets. Record your observations and analyse which sorting algorithm is faster.

Every line of code should be commented.

You should submit a word document in a report format containing:

  1. Introduction to Insertion Sort and Merge Sort
  2. Flow charts of both techniques
  3. Algorithms for both techniques used in your programs
  4. Run Time analysis by inputting different data sets
  5. Comparing the execution time in tabular format
  6. “Pretty Printed” Source code
  7. Screenshots of output.
  8. Future Scope
  9. Bibliography

Recommended Answers

All 3 Replies

Knuth, Volume 3, Sorting and Searching, has all the information you need. You should be able to find it in your school library...

For the testing just have the two programs accept the size of the array of numbers as a command line argument to sort then fill said array with random numbers. I did a similar project freshman year of college with quick sort and bubble sort as well and it makes it go much faster if you can just run the program with the number 1000000 and it will populate a randomized array of 1 million numbers then sort it. You can also script it so the times of when the program runs and finishes are recorded to have the most specific run times for each set of numbers, some sorts will be fast with small arrays some will be faster with large arrays.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.