▸ Implement two primary functions of queue: ▪ enqueue(): insert a node at the tail of a queue ▪ dequeue(): remove a node
Posted: Mon Jun 06, 2022 5:40 pm
PILTUUR LUI. #include <stdlib.h> struct queueNodel char data: struct queueNode nextPtr: }; typedef struct queueNode QueueNode: typedef QueueNode QueueNodePtr: void print Queue(QueueNodePtr currentPtr); int IsEmpty(QueueNodePtr headptr); char dequeue(QueueNodePtr headPtr, QueueNodePtr tailPtr): void enqueue QueueNodePtr headPtr. QueueNodePtr tailPtr, char value); void instructions(): void instructions() ( printf("Enter your choice: "); printf("et! to add an item to the queue #n"); printf("#t2 to remove an ites from the queue #n"); printf("t3 to endtn"): int isEmpty(QueueNodePtr headPtr) ( return headPtr = NULL: void print Queue(QueueNodePtr currentPtr) ( if (IsEmpty(currentPtr)) ( printf("Queue is emptynen): ) else ( printf("The queue is n"); while (currentPtr = NULL) { } printf("NULL "); printf("%c, currentPtr->data); currentPtr currentPtr->nextPtr: The main t QueueNodePtr headPtr NULL QueueNodePtr tailPtr = NULL: int choice: char item: instructions(): printf(" "); scanf-s("%d", Echoice): while (choice 1-3) ( switch (choice) ( case 1: while (1getchar()); printf("Enter a character: "); iten getchar(); enqueue(sheadPtr, StailPtr. item); printQueue(headptr); break; while (igetchar()); if (isEmpty(headPtr)) ( ites dequeuel SheadPtr. StailPtr): printf("%c has been dequeued #n", item); ) print Queue(headPtr); break: while (1getchar()); printf("Invalid choice. #ntn"); instructions(); break:
