Question: Write a C++ Code We are going to compare the performance between Arrays and Linked Lists. Please write C/C++ program following the procedure: 1. Suppose

Write a C++ Code

We are going to compare the performance between Arrays and Linked Lists. Please write C/C++ program following the procedure: 1. Suppose that N is 1000 (a number of data). 2. Generate N random numbers between 0 and 10000 (can be duplicated) 3. Store the numbers by using both an array and a Linked List. 4. Randomly select one index number between 0 and 200, and Add a random number to the index of the Array (or Linked List). For the array, the following data of the index element should move to the right. I.e. you should consider the extra space when you declare the array, or you can specify the array size by using new/malloc. 5. Repeat (4) one hundred times (i.e., add 100 random numbers) 6. Compute the processing time of (4) and (5), and print it. 7. Now, repeat (1) (6) setting N with 5000, 10000, and 20000.

Out put:-

The C/C++ program should print the progress and processing time (important). The output may look like: ----------------------------------------------------------------------------- N = 1000 1) We are generating data (N=1000) 2) New data are being added 3) Processing time Array: 5s Linked List: 2s -- N = 5000 1) We are generating data (N=5000) 2) New data are being added 3) Processing time Array: 25s Linked List: 10s -- N = 10000 1) We are generating data (N=10000) 2) New data are being added 3) Processing time Array: 250s Linked List: 100s

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!