Exercise: Algorithms

In this exercise you must do some time measuring on the sorting and searching algorithms.

You must make an "experiment" that shows if the algorithms really behave as expected

Sorting

Make an experiment that tries to sort some really large arrays of int's.

The data can be generated by random: Random Rand = new Random(); Rand.next().

Now sort the array using the Array.Sort(someArray) method, and measure the time (use the class StopWatch).

Do it again with an even larger array, and again, and again ...

Use a spread sheet (like Excel) to make some diagrams on your measurements.

Sorting Bubblesort

Bubblesort is a slow sorting algorithm.

Find a C# implementation of the Bubblesort algorithm.

Re-do the experiment above with the Bubblesort algorithm

Binary search

Binary search is a quick searching algorithm that works on sorted arrays.

Measure the time ...

Linear search

Linear search is a slow searching algorithm that works on any list.

Measure the time ...