Question: Run a small timing experiment to compare the cost of using vector and list. You can find an explanation of how to time a program

Run a small timing experiment to compare the cost of using vector and list. You can find an explanation of how to time a program in ยง26.6.1. Generate N random int values in the range [0:N ). As each int is generated, insert it into a vector (which grows by one element each time). Keep the vector sorted; that is, a value is inserted after every previous value that is less than or equal to the new value and before every previous value that is larger than the new value. Now do the same experiment using a list to hold the ints. For which N is the list faster than the vector? Try to explain your result. This experiment was first suggested by John Bentley.

Step by Step Solution

3.37 Rating (153 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

To compare the cost of using a vector and a list you can write a program that generates N random int... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Principles and Practice Questions!