Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

(ii) Develop the code for the following timing experiments. Report your results

ID: 665777 • Letter: #

Question

(ii) Develop the code for the following timing experiments. Report your results in the form of tables. The first column should indicate the size of the data structure. The remaining columns should report the measured times for the procedures that you apply. Derive conclusions out of your experiments and write them down.

3.(25 points) Perform time measurements of the following five operations on lists: iterated insertion (in front, at the back), traversal, iterated deletion (in front, at the back). Run each of your procedures on three types of lists: a selected list type library data structure, your implementation of the list ADT with arrays, your implementation of the list ADT with pointers.

C++ please

Explanation / Answer

Comments added

#include <iostream>
#include <list>
#include <time>
int main ()
{
clock_t t1,t2; //clock time objects declared
t1=clock();
std::list<int> mylist; //list declared
for(int i=0;i<500;i++){
mylist.push(i); //pushing into list from start
}
t2=clock();
float diff ((float)t2-(float)t1);
cout<<" push front time elapsed: "<<diff; //pushing into list from start
t1=clock();
for(int i=500;i<1000;i++){
mylist.push_back(i);//pushing into list from end
}
t2=clock();
cout<<" push back time elapsed: "<<diff;
t1=clock();
for(int i=0;i<500;i++){
mylist.pop(i); //pop list from start
}
t2=clock();
cout<<" pop time elapsed: "<<diff;
t1=clock();
for(int i=500;i<1000;i++){
mylist.pop_back(i); //pop list from end
}
t2=clock();
cout<<" pop_back time elapsed: "<<diff;
return 0;
}