C++ exercises and solutions: Queue item and operations


Queue

Queue item and operations


Step 1: Defining Queue item and function prototypes
Each item of the Queue contains two parts. One part is to store the integer value and another part to store the address of its next item.

typedef struct ListNode{

int data; // the element data
struct ListNode *next; // next link
}ListElem;

//---------------------------------------------------------
The operations associated with the Queue data structure can be outlined as the function prototypes shown below:


//Function prototypes
void addAtBack (int);//Add an item to the Queue
ListElem *removeAtFront();//Remove an item from the Queue
void printall();//print out all items on the screen
int countitem();//return the number of items in the Queue
ListElem *find(int);//find an item
ListElem *findmin();//find the min item
ListElem *findmax();//find the max item

//pfirst points the first item of the Queue and plast point to the last item

//of the Queue
ListElem *pfirst;
ListElem *plast;

You will find the definitions( code implementations) of the function prototypes in the next subsequent steps. See the left hand menu to find their links.


Comments




This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages:
C, C++, C#, Java, VB.NET, Python, VBA,PHP & Mysql, SQL, JSP, ASP.NET,HTML, CSS, JQuery, JavaScript and other applications such as MS Excel, MS Access, and MS Word. However, we don't guarantee all things of the web are accurate. If you find any error, please report it then we will take actions to correct it as soon as possible.