In C code assist with completing the following: #include queue.h #include #include //make a new empty queue
Question:
In C code assist with completing the following:
#include "queue.h"
#include
#include
//make a new empty queue
//Inputs: None
//Outputs: A Pointer to a new empty queue
//Side Effects: None
//Note: Remember to set all the values correctly
Queue* newQueue(){
//Implement me
return NULL;
}
//Determine if the Queue is Empty
//Inputs: Pointer to the Q
//Outputs: 1 if empty, 0 if contains values
//Side Effects: None
char isEmpty(Queue* Q){
//Implement Me
return 1;
}
//Add a new value to the Queue
//Inputs: Value to Add and pointer to Queue
//Outputs: None
//Side Effects: Allocates memory for new value
// and modifies Queue
void enqueue(int v, Queue* Q){
//Implement Me
return;
}
//Get value in front of queue
//Inputs: Pointer to Queue
//Outputs: First value in Queue or
// -1 if empty
//Side Effects: None
int front(Queue* Q){
//Implement Me
return 999;
}
//Remove the First Value from the Queue
//Inputs: Pointer to Queue
//Outputs: None
//Side Effects: Modifies Queue to remove first element
// Deletes first element from memory
//Reminder: Don't leak any memory!
void dequeue(Queue* Q){
//Implement Me
return;
}
//Print Queue to Help you Debug
//Inputs: Pointer to the Queue
//Outputs: None
//Side Effects: Prints the Queue to stdout
//Provided as a helper
void printQueue(Queue* Q){
if(Q->head==NULL){
printf("Empty Queue");
return;
}
Node* n = Q->head;
printf("Queue Contents: [");
while(n!=NULL){
printf("%d",n->value);
n=n->next;
if(n!=NULL){
printf(",");
}
}
printf("]");
return;
}
Queue.h listed here:
#ifndef _QUEUE_H_
#define _QUEUE_H_
/**
A structure to represent a single node in a one directional linked list.
*/
struct Node {
int value; /**< The value stored at this node. */
struct Node *next; /**< A pointer to the next node in the list. */
};
// Give the struct a short name
typedef struct Node Node;
/**
A structure to represent a classic Queue.
*/
struct Queue {
Node *head; /**< Pointer to the first value in queue. */
Node *tail; /**< Pointer to last value in the queue. */
};
// Give the Queue a short name
typedef struct Queue Queue;
/**
Create a new empty queue.
@return A pointer to the new queue struct
*/
Queue *newQueue();
/**
Determine if the queue is empty
@param Q is the queue to check
@return 1 for True and 0 for false
*/
char isEmpty(Queue *Q);
/**
Add a new value to the end of the queue
@param v is the value to add
@param Q is the Q to add the value to
*/
void enqueue(int v, Queue *Q);
/**
Determine the value at the front of the queue
@param Q is the queue to look at
@return The first value in the queue or -1 if the queue is empty
*/
int front(Queue *Q);
/**
Remove the first value from the queue
@param Q is the queue to remove from
*/
void dequeue(Queue *Q);
/**
Print the Queue to STD out. Used for debugging.
@param Q is the queue to print
*/
void printQueue(Queue *Q);
#endif
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill