Question: *please calculate the complexity of the program below : #include #include #include #include struct Queue // circular queue struct { int size; int front; int

 *please calculate the complexity of the program below : #include #include

*please calculate the complexity of the program below :

#include #include #include #include

struct Queue // circular queue struct { int size; int front; int rear; int *time_arr; };

int isEmpty(struct Queue *q) // function to check is queue is empty { if (q->rear == q->front) { return 1; } return 0; }

void enqueue(struct Queue *q, int time) // funntion to enqueue elements into the queue {

q->rear = (q->rear + 1) % q->size; q->time_arr[q->rear] = time; }

int dequeue(struct Queue *q) // funciton to dequeue elements from queue { int a = -1;

q->front = (q->front + 1) % q->size; a = q->time_arr[q->front]; }

int main() { // creating queue instances for gold and platinum customers struct Queue gold; struct Queue platinum;

// fixing size of queue as 10 , although user can change as per requirement gold.size = 10; platinum.size = 10;

// setting front and rear position of queue gold.front = gold.rear = 0; platinum.rear = 0; platinum.front = 0;

// dynamically allocating the queue array space gold.time_arr = (int *)malloc(gold.size * sizeof(int)); platinum.time_arr = (int *)malloc(platinum.size * sizeof(int));

printf("Enter total number of customers : "); int n; scanf("%d", &n); for (int i = 0; i

int random;

if (x == 1)

{

random = rand() % 30; enqueue(&gold, random); printf("your expected waiting time is %d ", random); }

if (x == 2)

{ random = rand() % 30; enqueue(&platinum, random); printf("your expected waiting time is %d ", random); } } printf(" "); while (isEmpty(&platinum) == 0)

{

printf("platinum customer with time %d served!!!! ", dequeue(&platinum)); }

while (isEmpty(&gold) == 0)

{ printf("gold customer with time %d served!!! ", dequeue(&gold)); }

return 0; }

Task 2: Complexity Analysis - Theoretically discuss and compute the complexity of all algorithms that you implemented. The discussion will describe your understanding of the algorithm. Define the complexity of the algorithm by using Big 'O' notation. Include the following statement at the first page of your report

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!