3. (Comparing Singly and Doubly Linked Lists) In this exercise we carry out some operations on std::list

Question:

3. (Comparing Singly and Doubly Linked Lists)

In this exercise we carry out some operations on std::list (call it A for convenience) and std::forward_list (call it B).

Answer the following questions:

a) Create instances of A and B with n elements, where n is typically a large number (for example, at least a million).

b) Insert an element at every alternate position in the lists A and B.

c) Remove all even elements from the lists A and B.

d) Sort and reverse the lists A and B.

e) Create an instance of B with n elements all of whose values are the same value val.

Compare the run-time efficiency of using a single call to remove all the elements with value val and removing elements one by one.

Use the stopwatch class to measure the relative run-time performance in all cases.

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

Step by Step Answer:

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