Share
Explore BrainMass

Design a Queue Abstract Data Type Enqueue, Dequeue, Empty

I need to know how I would do the following program...simple please I have minimal C, C# or C++ background.

Design a queue abstract data type, including operations for enqueue, dequeue, and empty.

Solution Preview

I have added extensive comment to C code. Also added the executable as created by Miracle C.

#include <stdio.h>
#include <stdlib.h>
#define FALSE 0

typedef struct linkedlist{ //its a linked list of elements
int dataitem; //We can store an integer data item
struct linkedlist *next; // a pointer to the next item in the queue
} queue; // Queue Abstract Data structure

void Menu (int *choice); //User Menu to enter choices for the Queue
queue *enqueue (queue * Qpointer, int data); //Function to add an item to the tail/end of the queue
queue *dequeue (queue * Qpointer); //Function to get (and delete) an item to the head/beginning of the queue
void printQ (queue *Qpointer); //Print the Queue by starting from the beginning, following the chain of links until the end (NULL) has reached
void empty (queue *Qpointer); //Emtpy/clear the Queue

int main () { //The main() function
queue *Qpointer;
int ...

Solution Summary

I have added extensive comment to C code. Also added the executable as created by Miracle C.

$2.19