Evaluate the following sorting algorithms using operations counters instrumented into the program code :
You must write functions to make comparisons and to swap elements. These functions can then also increment counters for the operations. (count all comparison operations with one counter rather than have separate ones for < and >)
Note that MergeSort does not have a concept of swapping elements. For this only the comparisons will suffice.
Run each algorithm for varying numbers of elements (random values inserted into an array, but with the same set for each algorithm) from n=100 to n=1000 in increments of 100. Use integers as the element type.
After sorting each set of elements, use a function to check that the elements are indeed sorted - indicate this on your output as well.
Finally, draw graphs of "Comparisons vs N" and "Swaps vs N". Each graph should have a line for each of the sorting algorithms, as well as the expected asymtotic functions, n^2 and nLog n.