Home > Back-end >  Data structure in the chain of the queue team operation
Data structure in the chain of the queue team operation

Time:11-29

Chain queue team code this is the data structure (as from online copy), I don't know why s next domain will never equal to NULL, so can't together with the other nodes,
//insert a new element of the
Int InsertQueue (LinkQueue & amp; Q, QElemType e)
{
QueuePtr s=(QueuePtr) malloc (sizeof (QNode));
if (! S)
{
Cout & lt; return ERROR;
}
S - & gt; Data=https://bbs.csdn.net/topics/e;
S - & gt; Next=NULL;
Q.r ear - & gt; Next=s;
Q.r ear=s;
return OK;
}

CodePudding user response:

S - & gt; Next=NULL; Can be understood as initialization, s is a link to the end of the queue, the queue at the end of the next is not executed NULL?
The original poster can have a look at the queue traversal by judging whether NULL to determine if, at the end of the

New nodes come in, will be put on a s - & gt; NULL to cover the next, is to use the new cover on a s - s & gt; next

CodePudding user response:

Next of nodes connected to a new domain, the new node of the next point to NULL,
  • Related