Home > Net >  Singly linked list node insert
Singly linked list node insert

Time:09-21

Node insert way I have been think it over, but I'm in the Program class difficult don't know how to insert node assignment,
Is this: to define the Node insertNode,
InsertNode. NextNode doesn't know what should I do to make insertNode this insert node can be inserted into the corresponding node position,
Here, please ignore the standardization of the code I wrote, thank you teach, if there is a way, it is best to post code, thank you,

CodePudding user response:

Already exists two nodes, for example, a, b, a.n extNode=b, b.n extNode=null
1, insert the node c, citigroup extNode=a, list for c, a, b,
2, insert the node c, citigroup extNode=null, list for a, b, c,
3, other, omitting dozens of words here,

CodePudding user response:

Assumptions, the original is a - c node, now insert node b
That should be modify a node nextNode pointing b
And then, b nextNode to a c

CodePudding user response:

refer to the second floor is nu month god reply:
assumption, now turned out to be a - c node, insert node b
That should be modify a node nextNode pointing b
Then, b nextNode to c

Yes, yes, if I wrote that, you are directly connected to the node after next, just at the time of test, if directly insert node point to the next node must be empty, is don't know what to do here

CodePudding user response:

Insert node, you find a node in a first,
A nextNode is c.
So after insertion, set a.n extnode=b, b.n extnode=c,
  •  Tags:  
  • C#
  • Related