Reference no: EM133241258
Question: C++ console app, applying the timing test code to an operation that requires scanning the entire vector of names read from the file.
You're looking for some operation that's close to O(n) here. Here are a few examples of loops that would work:
Finds the shortest name in the array
Finds the longest name in the array
Counts how many times a particular first name occurs, like "Victoria"
To perform the timing tests, you will set the starting size with the variable 'n' at the top of main(), which controls how many lines your algorithm will use for input. Also set 'bigOh', which represents your "guess" about your algorithm.
Start with n = 50,000 for the first cycle, and set bigOh to O(n) -- that is, we expect that the time it takes to read the file is directly proportional to the number of lines read from the file.
It is possible that caching may throw off the timing for the first cycle, so run your program more than once to see it work correctly. Your timings will not be an exact match for the 'expected' amounts each time, but should be close.