Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Assume we have the following definition of a Queue. Add appropriate functionalities to transform it into a Deque. #include #include #include #include / / A

Assume we have the following definition of a Queue. Add appropriate functionalities to transform it into a Deque.
#include
#include
#include
#include
// A structure to represent a queue
struct Queue {
int front, rear, size;
unsigned capacity;
int* array;
};
// function to create a queue of given capacity.
// It initializes size of queue as 0
struct Queue* createQueue(unsigned capacity){
struct Queue* queue =(struct Queue*)malloc(sizeof(struct Queue));
queue->capacity = capacity;
queue->front = queue->size =0;
queue->rear = capacity -1;
queue->array =(int*)malloc(queue->capacity * sizeof(int));
return queue;
}
//You may assume the following functions have been implemented and can be used by you
int isFull(struct Queue* queue); // returns true if the queue is full
int isEmpty(struct Queue* queue); // Returns true if the queue is empty
void enqueue(struct Queue* queue, int item); // Adds the item to the rear of the queue
void dequeue(struct Queue* queue); // Removes the item at the front of the queue
int front(struct Queue* queue); // Returns the item at the front of the queue
// Add fully defined functions to complete the Deque's functionality

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DATABASE Administrator Make A Difference

Authors: Mohciine Elmourabit

1st Edition

B0CGM7XG75, 978-1722657802

More Books

Students also viewed these Databases questions