Write a c++ code that compare the times to traverse a list (containing a large number of elements) implemented in an array, in a simple linked list, and in an unrolled linked list.
Write a c++ code that compare the times to traverse a list (containing a large number of elements) implemented in an array, in a simple linked list, and in an unrolled linked list. In this experiment, you need to generate a large list, store it in each representation, and then measure the time to traverse the list in each representation. For the array, this is almost straightforward: Fill the array and then do a sequential scan. Here is the thing to watch for: When you fill the array, it all gets read into cache. So, somehow you need to ensure that almost all of the array is NOT in cache before you do your traversal. One thing you can do is make your array big enough that most of it will not fit in cache at once. You need to make sure that the node capacity is not too small, or it will behave too much like a simple linked list.
Step by step
Solved in 2 steps