# Sorting algorithms

You are to compare two sorting algorithms and to compare two searching algorithms by running and collecting data on each. Your data for sorting and searching will be strings of 25 characters in length.

First Part:

The two sorts to compare are the Bubble Sort and the Selection Sort. You are to test your sorts against different set of strings. Each sort will sort six sets of data, 1000 strings, then 2000 strings, 3000, 4000, 5000 and 6000 strings. You will compare how well each sort did with the different data sizes and show results. I would like to see a plot of the results. A table format showing results will do. Use the ‘time’ function and the ‘difftime’ function to gather sort times.

Second Part:

The two searches to use for comparisons are the Linear Search and the Binary Search. You will search for 2000 random strings in the array of 6000 strings and compute the average number of probes needed to find a match. The target string will be a randomly selected string from the 6000 string’s data set. You will select randomly 2000 strings for testing each search algorithm.

You are to generate 25 random characters for each string for your string data sets.

Hint:

char charset[52]; “a b c … A B C … Z”;

string randomstr;

for ( i = 1; i <=25; i++ )

{ randomndx = rand() % 56;

randomstr = randomstr + charset[ randomndx ]; //concat char to string

}

First Part:

The two sorts to compare are the Bubble Sort and the Selection Sort. You are to test your sorts against different set of strings. Each sort will sort six sets of data, 1000 strings, then 2000 strings, 3000, 4000, 5000 and 6000 strings. You will compare how well each sort did with the different data sizes and show results. I would like to see a plot of the results. A table format showing results will do. Use the ‘time’ function and the ‘difftime’ function to gather sort times.

Second Part:

The two searches to use for comparisons are the Linear Search and the Binary Search. You will search for 2000 random strings in the array of 6000 strings and compute the average number of probes needed to find a match. The target string will be a randomly selected string from the 6000 string’s data set. You will select randomly 2000 strings for testing each search algorithm.

You are to generate 25 random characters for each string for your string data sets.

Hint:

char charset[52]; “a b c … A B C … Z”;

string randomstr;

for ( i = 1; i <=25; i++ )

{ randomndx = rand() % 56;

randomstr = randomstr + charset[ randomndx ]; //concat char to string

}

You'll get a 3.6KB .ZIP file.