Question: Which is faster for a simple program, a vector or a list? Write two programs, vcount using a vector and lcount using a list. In
Which is faster for a simple program, a vector or a list?
Write two programs, vcount using a vector and lcount using a list.
In each program, generate a million random numbers between and Add them to the data structure. see hint below on how to generate random numbers
Then write a loop that goes from to uses the algorithm count, and prints how many ss etc up through how many s occur in the data.
Find out how long each program takes to run by using the time program: time vcount and time lcount
Put the programs in your afs area.
Put a note on Moodle saying how long each took to run, and why you think one was faster than the other.
Hint: for random numbers, look at man srand Basically, you have to seed the random number generator once at the beginning. Typically that's done by saying
srandtime;
which will seed the random number generator with the current time. Then to generate a random number through use
rand;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
