Question: 1 . Analyze the operation opB ( below ) for its worst case performance by , i . Showing the number of times each statement

1. Analyze the operation opB (below) for its worst case performance by,
i. Showing the number of times each statement is executed.
ii. Showing the mathematical function F(n) for opB
iii. Showing the upper bound (Big-O) of function F(n)
void opB (IntegerQueue& r)
//! restores r
//! ensures: the contents of r is displayed
{
int x, z;
z = r.length(); // S1
for (int k =0; k < z; k++){// S2.1, S2.2, S2.3
if(k ==0){// S3
cout <<"<"; // S4
}// end if
cout << r.front()<< endl; // S5
if (k ==(z -1)){// S6
cout <<">"; // S7
}// end if
r.dequeue(x); // S8
r.enqueue(x); // S9
}// end for
}// opB

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 Programming Questions!