CodePudding user response:
A pmid two Pointers, a pend pmid walk the one step at a time, take two steps pend until pend on the end, the pmid is the middle position,Seem to be effective, the best in the length of the head nodes stored in a single table,
CodePudding user response:
ElemType Midnode (LinkNode * L)
P={LinkNode * L - & gt; Next, * q=p;
While (p - & gt; Next!=NULL & amp; & P - & gt; Next - & gt; Next!=NULL)
{p=p - & gt; Next - & gt; Next;
Q=q - & gt; Next;
}
Return the q - & gt; The data;