Tom3333
asked on
queue print function
I would like to create a function which print all the nodes of the queue (i have already create all the other functions (for example add new node etc))
The structure which i used :
typedef struct node
{
char *name;
int Identity;
int time;
struct node *next;
} NODE;
typedef struct
{
NODE *head;
NODE *tail;
int size;
} QUEUE;
How to create the function for print all the nodes of the queue???????
The structure which i used :
typedef struct node
{
char *name;
int Identity;
int time;
struct node *next;
} NODE;
typedef struct
{
NODE *head;
NODE *tail;
int size;
} QUEUE;
How to create the function for print all the nodes of the queue???????
No, sorry, that was for binary tree, rather than for queue
ASKER
Something else about queue?
Have you created funtion pop() which would get the highest element of the queue and remove it form the queue ?
and function empty() which will check id the queue is empty? and function print() for printing the node?
with all these functions, I think, something like that should work
while (!empty(q)){
NODE n = pop(q);
print(n);
}
ASKER
Is anyone who know any web site with information about queue with double link list ????
Easy way to print all nodes from your queue is:
QUEUE q;
NODE n;
...
for (n = q->head;
n != NULL;
n = n->next)
printf("%s %d %d\n", n->name, n->Identity, n->time);
QUEUE q;
NODE n;
...
for (n = q->head;
n != NULL;
n = n->next)
printf("%s %d %d\n", n->name, n->Identity, n->time);
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I think thos one from
http://www.geeksforgeeks.org/archives/2686
shows how to do it:
Open in new window