#includestdio.h
#define max 6
int queue[max];
int front=-1;
int rear=-1;
// for dequeue
void dequeue() {
if(front==-1 && rear==-1) {
printf("the queue is empty");
} else if(front ==rear){
printf("\nThe dequeued element is %d", queue[front]);
front=-1;
rear=-1;
} else {
printf("\nThe dequeued element is %d", queue[front]);
front=(front+1)%max;
}
}
void display(){
int i=front;
if(front==-1 && rear==-1) {
printf("\nQueue is empty..");
} else {
printf("\nElements in the queue are: ");
while(i=rear) {
printf("%d,", queue[i]);
i=(i+1)%max;
}
}
}
int main(){
int element;
dequeue(); // calling the dequeue function
display();
return 0;
}
What are the time and space complexity of the deque and display functions?