
typedef struct queue * Queue; Queue queueCreate(int maxSize); void enqueue(Queue q, int item); int queueFront(Queue q); int dequeue(Queue q); int queueSize(Queue q); void queueDestroy(Queue q)
/*
* Queue.h
*
* Created on: 28-Jul-2020
* Author: naren
*/
#ifndef SRC_QUEUE_H_
#define SRC_QUEUE_H_
#include <stdio.h>
#include <stdlib.h>
/**
* structure for queue
* *array to store items
* capacity maxSize of queue
*/
struct queue{
int *array;
int capacity;
int front;
int rear;
};
typedef struct queue *Queue;
/**
* function to create queue of given size
*/
Queue queueCreate(int maxSize);
/**
* function to enqueue an item into queue
*/
void enqueue(Queue q, int item);
/**
* function to get an item from front of the queue
*/
int queueFront(Queue q);
/**
* function to dequeue an item from the queue
*/
int dequeue(Queue q);
/**
* function to get size of the given queue
*/
int queueSize(Queue q);
/**
* function to destroy given queue
*/
void queueDestroy(Queue q);
#endif /* SRC_QUEUE_H_ */
/*
* Queue.cpp
*
* Created on: 28-Jul-2020
* Author: naren
*/
#include "Queue.h"
Queue queueCreate(int maxSize){
Queue q = (Queue) malloc(sizeof(struct queue));
q->array = (int *) malloc(sizeof(int) *
maxSize);
q->front = -1;
q->rear = -1;
q->capacity = maxSize;
return q;
}
void enqueue(Queue q, int item){
if (q->rear +1 != q->capacity){
if (q->rear == -1){
q->front++;
}
q->rear++;
q->array[q->rear] =
item;
}
}
int queueFront(Queue q){
if (q->front == -1){
return -1;
}
return q->array[q->front];
}
int dequeue(Queue q){
int front = q->array[q->front];
q->front++;
if (q->front > q->rear){
q->front = -1;
q->rear = -1;
}
return front;
}
int queueSize(Queue q){
if(q->front == -1){
return 0;
}
return (q->rear - q->front + 1);
}
void queueDestroy(Queue q){
free(q);
}
/*
* testQueue.c
*
* this is my testQueue
file. you can use your own
*
* Created on: 28-Jul-2020
* Author: naren
*/
#include "Queue.h"
int main(){
// create a queue
Queue q = queueCreate(5);
enqueue(q, 23);
enqueue(q, 20);
enqueue(q, 34);
// test for function queueSize
if (queueSize(q) == 3){
printf("test Queue size
passed.\n");
} else {
printf("test Queue size
failed.\n");
}
// test for function queueFront
if (queueFront(q) == 23){
printf("test Queue front
passed.\n");
} else{
printf("test Queue front
failed.\n");
}
// test for function dequeue;
dequeue(q);
if (queueFront(q) == 20){
printf("test deQueue
passed.\n");
} else{
printf("test deQueue front
failed.\n");
}
queueDestroy(q);
}
Output:

typedef struct queue * Queue; Queue queueCreate(int maxSize); void enqueue(Queue q, int item); int queueFront(Queue q);...
Array-based Queue Lecture 6 Two Class Exercises | Class Exercise #1 - Create an array-based queue that holds values of double data type. 1.) Create a program that produces the following output OUTPUT: Q Quit Enter your choice: e Enter an item: 1.1 E Enqueue D Dequeue s-show queue ← showMenuO function called in main) OQuit // screen clears-.. continue enqueuing.screen clearing with each iteration Enter your choice: e Queue is full. E Enqueue D Dequeue s Show queue 0...
Write a function that takes a string parameter and determines whether the string contains matching grouping symbols. Grouping symbols are parenthesis ( ) , brackets [] and curly braces { }. For example, the string {a(b+ac)d[xy]g} and kab*cd contain matching grouping symbols. However, the strings ac)cd(e(k, xy{za(dx)k, and {a(b+ac}d) do not contain matching grouping symbols. (Note: open and closed grouping symbols have to match both in number and in the order they occur in the string). Your function must use...
AQueue.java
class AQueue implements Queue {
private E queueArray[]; // Array holding queue elements
private static final int DEFAULT_SIZE = 10;
private int maxSize; // Maximum size of queue
private int front; // Index of front element
private int rear; // Index of rear element
// Constructors
@SuppressWarnings("unchecked") // Generic array allocation
AQueue(int size) {
//BUG #1: maxSize = size
maxSize = size+1; // One extra space is allocated
rear = 0; front = 1;
queueArray = (E[])new Object[maxSize]; //...
Getting started with Java on elvis Download Greeting.java from the class web site. Use FileZilla to place it into your Lab5 directory. Look at the content of your directory to see the file using the command ls Look at the content of the file in your directory using the command more Greeting.java Compile the HelloClass program using the command javac Greeting.java. Then use ls to see your class file. Run the program without parameters using the command java Greeting Run...
Design and implement a class Q that uses Q.java as a code base. The queue ADT must use class LinkedList from Oracle's Java class library and its underlying data structure (i.e. every Q object has-a (contains) class LinkedList object. class Q is not allowed to extend class LinkedList. The methods that are to be implemented are documented in Q.java. Method comment blocks are used to document the functionality of the class Q instance methods. The output of your program must...
Code a queue data structure to store the Grocery, Meat, and
Produce object instances created during program execution.
Transform your code to use the queue instead of the array. It is
recommended to create a new class file, however, to retain the
prior version of your course project. You can copy your code from
the prior module into your new class file to get started. Leverage
your file-processing code from the prior Module. Include
appropriate package import declarations as needed....
C++ -- Event processing simulation using a transaction queue Hi! it is queue simulation please read the instructions, write codes, and explain the code with comments. Thank you Transactions enter the system and are stored in a queue. Each transaction represents some work that needs to be accomplished. Servers exist which process transactions. Servers take transactions off the queue and process them. you’re building the simulation framework. The idea is that somebody would take your framework, and add the specifics...
Instructions Download the files towardsHashTables.cpp, and Queue.h. This is the incomplete example from class last week, where we started implementing a hash table as a vector of queues. In order for this example to work, the Queue struct needs 3 more functions to be implemented. A find function, which tells us it a given value appears in the queue, without being destructive. A function called print, which prints out the contents of the queue, again without being destructive. Finally, there...
Hi! it is c++ queue simulation please read the instructions, write codes, and explain the code with comments. Thank you Transactions enter the system and are stored in a queue. Each transaction represents some work that needs to be accomplished. Servers exist which process transactions. Servers take transactions off the queue and process them. you’re building the simulation framework. The idea is that somebody would take your framework, and add the specifics for whatever type of system it was going...
Star Database Program. This is a more sophisticated assignment, it will take longer to do. Write a program which uses file IO, loops, and function calls. The following files are provided in pub: Assignment.cpp stars.dat solution_stars.dat solution.o when you log in the first time, make a directory for this project mkdir prog3 then copy down the files. (WARNING! This will overwrite any file in the directory named Assignment.cpp, so don't copy down Assignment.cpp if you have already done work): cp...