Question: #include #include #include using namespace std; const int MAX = 25000; //array size //static array void f1 () { static int a[MAX]; for (int i

#include

#include

#include

using namespace std;

const int MAX = 25000; //array size

//static array

void f1 () {

static int a[MAX];

for (int i = 0; i

return;

}

//fixed stack-dyanmic array

void f2 () {

int a[MAX];

for (int i = 0; i

return;

}

//fixed heap dynamic array

void f3 () {

int *a = new int[MAX];

for (int i = 0; i

return;

}

int main(){

int num;

int iter = 10;

clock_t t1,t2,t3;

for (int i = 0; i < iter; i++)

{

cout << "Enter number of iterations: ";

cin >> num;

t1 = clock();

for (int j=0; j

{

f1();

}

t1=clock() - t1;

t2=clock();

for (int j=0; j

{

f2();

}

t2=clock() - t2;

t3=clock();

for (int j=0; j

{

f3();

}

t3=clock()-t3;

cout << "f1 (Static array) execution time (in cycles): " << t1 << endl;

cout << "f2 (stack array) execution time (in cycles): " << t2 << endl;

cout << "f3 (heap array) execution time (in cycles): " << t3 << endl;

cout <

}

system("pause");

return 0;

}

DISPLAY AND OBSERVE THE RESULTS. BRIEFLY EXPLAIN THE RESULTS AND JUSTIFY YOUR OBSERVATION. IN DETALS PLEASE

EXPLAIN THE RESULTS OF THE STATIC STACK AND HEAP ARRAY EXPLAIN RESULTS AND WHY

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!