All of the work in this project is my own!  I have not left copies of my code in public folders on university computers. I have not given any of this project to others. I will not give any portion of this project to others taking this class. I realize that the penalty for turning in work that is not my own can range from an "F" in the class to dismissal from Trinity University. 

                                    Print Name  __________________________    Time Required = ______.____ Hrs.

                                    Signature   __________________________

                                     Print Name  __________________________

                                     Print Name  __________________________   

                                     Print Name  __________________________

                                     Print Name  __________________________   
 

_________ The AvrRead for file RanAthletes-10.fil is _?_ sec

_________ The AvrRead for file RanAthletes-100.fil is _?_ sec

_________ The AvrRead for file RanAthletes-1000.fil is _?_ sec

_________ The AvrRead for file RanAthletes-10000.fil is _?_ sec

_________ The AvrRead for file RanAthletes-100000.fil is _?_sec

_____________________ If 100,000 records were place in an unordered direct access file, the average time to find a record would be _?_ seconds.

_____________________ If 100,000 records were place in an unordered direct access file, the worst-case time to find a record would be _?_ seconds.

_____________________ If you chose to sort 100,000 records using an order N2 sort, it would probably take about _?_ hours to sort.

_____________________ If you chose to sort 100,000 records using an order N Log2 N sort, it would probably take about _?_ hours to sort.

_____________________ Once you have sorted the 100,000 records, it would take no more than _?_ Reads to find a record by the sort key. (worst-case)

_________ The worst-case time to find a record (by sort key) in RanAthletes-100000.fil would be _?_sec

_____________________ Once you have sorted the 100,000 records, it would take an average of _?_ Reads to find a record by the sort key. (average-case)


Athlete Timing II - Read/Write
Individual/Team (1-3 Persons) Assignment
35 Points

Make Any Changes Necessary For Compilation


You Will Be Answer Questions As You Complete This Lab
Turn In One Copy Per Team

Use one of the computers in our class room to collect the final data for Part II this project.


Create the Project

1]  Copy Athlete-Timing-1-Tom-Maurice to Athlete-Timing-2-Tom-Maurice to <== replace Tom-Maurice  with the first names of each team member.

2] Make sure that the sizeof(Athlete) = 10,000 bytes exactly! Use char Satellite[??] to pad the record.

3] WIth the exception of the RandNo, ReadRecord, WriteRecord, DisplayFile, and FileLength, put the components for this lab in Main.cpp


Clock Functions

3] Figure out how to use the clock in the time.h library. Write Function StartClock( ) which starts the clock. Write Function StopClock which stops the clock. Write Function CalculateTimeSeconds which determines how many seconds the clock ran.


main

1] Place your project in the Temp folder on one of the computers in Halsell 228. Run the following main program.

    CreateRandomAthleteNodeFile("RanAthletes-10.fil", 10);
    CreateRandomAthleteNodeFile("RanAthletes-100.fil", 100);
    CreateRandomAthleteNodeFile("RanAthletes-1000.fil", 1000);
    CreateRandomAthleteNodeFile("RanAthletes-10000.fil", 10000);
    CreateRandomAthleteNodeFile("RanAthletes-100000.fil", 100000);
    DisplayFile("RanAthletes-10.fil", Athlete1, "\n\nAthletes 1-10\n");

2] Restart the computer.


Create Function  TimeRandomAthleteFile(char FileName[ ], long int NoRecords, double & AvrRead,  double & TotalSeconds  )

1] Remember that we shall not use Record 0

2] Dynamically create an array Info that contains NoRecords + 1 integers and fill that array with values 1, 2, 3, 4, ..., NoRecords

   ----------
10 |     10 |
   ----------
 9 |      9 |
   ----------
 8 |      8 |
   ----------
 7 |      7 |
   ----------
 6 |      6 |
   ----------
 5 |      5 |
   ----------
 4 |      4 |
   ----------
 3 |      3 |
   ----------
 2 |      2 |
   ----------
 1 |      1 |
   ----------

3] Do the following with a loop 2 x NoRecords times:

    Fill Rand1 with a random number between 1-NoRecords (3).

    Fill Rand2 with a random number between 1-NoRecords (6).

    Swap the contents of Info[3] and Info[6]

4] By the time you do this 2 x NoRecords times, the data will be pretty well sorted and it will contain all of the values 1, 2, 3, ..., NoItems in random order. It might look something like the following:

   ----------
10 |      2 |
   ----------
 9 |      5 |
   ----------
 8 |      1 |
   ----------
 7 |     10 |
   ----------
 6 |      6 |
   ----------
 5 |      8 |
   ----------
 4 |      4 |
   ----------
 3 |      7 |
   ----------
 2 |      3 |
   ----------
 1 |      9 |
   ----------

5] To calculate the average search, we are going to read each record one time in random order.

6] Start the clock

7] Use the array to determine the read order. If Info contains the collection above, your function will read Record 9, Record 3, Record 7, Record 4, Record 8, Record 6, Record 10, Record 1, Record 5, Record 3

8] Stop the clock and determine the number of seconds (Suppose it were 2.3 seconds)

9] The average time to Read a Record and Write a Record are generally so close to the same, that we simply refer to the time as the AvrRead or AvrWrite time. Take the total number of seconds (perhaps 2.3) and divide it by the NoRecords (perhaps 10) and return the AvrRead time (.23 seconds); return the TotalSeconds. Make TotalSeconds a double.


final main

Restart the computer before you collect your final data.

//    CreateRandomAthleteNodeFile("RanAthletes-10.fil", 10);
//    CreateRandomAthleteNodeFile("RanAthletes-100.fil", 100);
//    CreateRandomAthleteNodeFile("RanAthletes-1000.fil", 1000);
//    CreateRandomAthleteNodeFile("RanAthletes-10000.fil", 10000);
//    CreateRandomAthleteNodeFile("RanAthletes-100000.fil", 100000);
//    DisplayFile("RanAthletes-10.fil", Athlete1, "\n\nAthletes 1-10\n");

Your main program shall display the following commercial

        Random Athlete Direct Access File Application
               Calculate AvrRead & AvrWrite
                         written by
                           ??????

Your main program shall display the following for each of your four files:

File Name  : RanAthletes-10.fil
No Records : 10
Total Time : 2.3 Seconds
Avr Access : .23 Seconds

 


Erase The Data Files

Erase the five data files from your folder before you copy it to Ananke:

    RanAthletes-10.fil

    RanAthletes-100.fil

    RanAthletes-1000.fil

    RanAthletes-10000.fil

    RanAthletes-100000.fil


Backup

1] Make sure you erased the data files - backups will be too slow if you do not.

2] Backup this project on your Y drive. Back up this project on a thumb drive or your personal computer. Put a copy in each team members "To Be Graded Folder" on Ananke.


1] Those Labs labeled "Individual Assignment" are to be done separately by each individual. Using a pen,  each individual is to print  his/her Title at the top of this document in the space provided and sign it.  Those Labs labeled "Team Assignment" may be done as a team or individually. Using a pen,  each individual on the team is to print print his/her Title at the top of this document in the space provided and sign it.


Turn In The Following

A] Using an ink pen, print your Name and sign  page 1 of this lab at the top. Answer the questions on the first page. Record the amount of time you spent working on the lab.

B] Print the output file - remove any personal diagnostics. Staple to the back of this lab sheet.

C] Print main.hpp. Staple to the back of this lab sheet. The FileLength, ReadRecord, WriteRecord, RandNo, and DispalyFile may well be in the Utilities hpp/cpp; don't print the utility files unless you added the major components of this program to that directory. I want to see

D] Make sure you erased the data files - backups will be too slow if you do not.

E] Never place your only copy of your project just on Ananke. Never leave a copy of your project on a public server. Always maintain a copy your project to your Y drive. Always maintain a copy your project on your personal computer.

F] Nothing will be graded until this lab form is submitted.  Staple the pages. Fold the lab Horizontally (like a hot dog) and write your name nice and large on the outside.  Place it on the professor desk before the beginning of lecture on the day it is due. All assignments are due the next class period unless otherwise designated on the schedule page.