Solved:Lab 4: Circular Queue ADT

$24.99 $18.99

Implement Circular Queue ADT using an array. Your Circular Queue ADT has two main operations, Enqueue and Dequeue. In addition, you should implement two more functions for printing the first element and the last element. Enqueue a new element at the end of the element in the queue. If your queue is full, just print…

5/5 – (2 votes)

You’ll get a: zip file solution

 

Categorys:

Description

5/5 – (2 votes)

Implement Circular Queue ADT using an array. Your Circular Queue ADT has two main operations, Enqueue and Dequeue. In addition, you should implement two more functions for printing the first element and the last element.

  • Enqueue a new element at the end of the element in the queue. If your queue is full, just print an error message.
  • Dequeue the node in the front. If your list does not have any element, just print an error message.
  • PrintFirstElem print the first element in the queue. If your queue is empty, just print an error message.
  • PrintLastElem print the last element in the queue. If your queue is empty, just print an error message.
  1. Input

Obtain a list of operations from the given input file, and execute the given operations in order. A detailed specification of the operations is provided below. Each line represents a single operation. Each operation and the necessary parameters are separated by a space. You may assume that the input values (represented as x and y below) are any characters. Note that max_queue_size is the number of elements that can be stored in the queue.

  • e x: enqueue a new element with the key “x” after the last element
  • d : dequeue the first element in the queue
  • f : print the first element in the queue
  • r: print the last element in the queue
  • n x: create a new queue with the size of x. The number x is the maximum size of the queue. This operation will always be given in the first line of the operations in your input file.

An input file is shown below.

  1. CircularQueue ADT

(1) Data Specification for the objects

typedef struct CircularQueue {

int *key;

int front;

int rear;

int max_queue_size;

}CircularQueue;

(2) Function specification

  • void MakeEmpty(CircularQueue *Q, int max );

  • int IsEmpty( CircularQueue *Q );

  • int IsFull( CircularQueue *Q );

  • void Dequeue( CircularQueue *Q );

  • void Enqueue( CircularQueue *Q, int X );

  • void PrintFirst (CircularQueue *Q);

  • void PrintRear (CircularQueue *Q);

3. Program description

  • name : p4.c

  • input : a list of operations in a file (an input file name is given as a command line argument. See an example in “1. input” on the first page)

  • output : the corresponding result in the standard output

Submit to the course gitlab your source code. (~2020/4/16 23:59)

Solved:Lab 4: Circular Queue ADT
$24.99 $18.99