| Article Index |
|---|
| LINEAR QUEUE IMPLEMENTATION USING LINKED LIST |
| Introduction |
| Source Code |
| Documentation |
| All Pages |
Goal :
The aim of this code is to perform the basic linear queue operations and has to inform underflow during necessary situation.
Variable Used :
|
Variable |
Data Type |
Task Of The Variable |
|
ne |
*node |
Since the data type is a pointer, the variable ne is also a pointer. The variable ne is the pointer to a structure. |
|
end |
*node |
Since the data type is a pointer, the variable end is also a pointer. The variable end is the pointer to a structure. |
|
header |
list(*node) |
The list is a user defined data type. The header is the first node in the list |
|
element |
integer inside the structure |
The element is present inside the structure. So it can be accessed only through the structure variables (ne,end,header). Since the ne and end are pointers, to access the element we have to use arrow operator (e.g ne->element,end->element) . |
|
next |
Structure pointer inside the structure |
The next is present inside the structure. So it can be accessed only through the structure variables (ne,end,header). Since the ne,header and end are pointers, to access the next we have to use arrow operator (e.g ne->next,end->next,header->next) . |
|
e |
integer |
Variable used for storing the integer in our program |
|
i |
integer |
Loop variable |
|
s |
integer |
Switch variable which will select any one of the cases |
Function Used :
|
FUNCTION NAME |
RETURN TYPE |
PARAMETERS |
TASK OF THE FUNCTION |
|
createqueue |
queue |
----- |
It will allocate memory for a header node (which contain data and address field) |
|
isempty |
int |
header |
Check whether the queue is empty or not(return 1 if the queue is full else it will return 0) |
|
enqueue |
void |
header,e |
Insert the element in the queue |
|
dequeue |
void |
header |
Delete the element in the queue |
|
frontanddelete |
int |
Header |
Delete the element in the queue and also display the deleted element |
|
front |
int |
header |
Display the front element in the queue |
|
search |
void |
header,e |
This function will search whether the element is present in the current list and display the current position if it is present in the list. |
|
display |
void |
header |
Display all the elements that present in the queue |
Implementation :
- The main call the createqueue function which will built the header node and initialize as well.
- Then using Switch case we can select the task to perform.
- Each function will perform their own task.
| < Prev | Next > |
|---|




