Run a small timing experiment to compare the cost of using vector and list. You can find

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 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.

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: