CS120
Lab #10

Due at the end of lab.

For this lab you need to write a program to do three things:

To read in the names you will need to create an ifstream object (ifstream stands for "input file stream") and connect it to the namedata.txt file. The names can be stored in an array of stings (of size 2000).

The search should be done by a separate function that recieves three arguments: the array, the size of the array, and the string/name to search for. The function should return -1 if the name is not in the array and the location of the name (a number between 0 and 1999) if the name is in the array. The main() function should print the message saying whether or not the name is present and it's location if it is present.

There should be a separate function to sort the array. This function should take two arguments, the array and the size of the array.

Extra Credit: Write another function that searches the sorted array using a binary search algorithm. Report the number of steps taken by the regular search algorithm and the number of steps taken by the binary search algorithm when each one is searching for a name that is not in the list (the worst case).

Turn in: Your code and sample output. The output should show the program finding a name that is in the list, reporting a name that is not in the list, and the sorted list. If you do the extra credit include output showing appropriate output for that code as well.