Skip to content

Instantly share code, notes, and snippets.

@irrationnelle
Created November 2, 2015 19:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save irrationnelle/4ba25913fa1c42e68445 to your computer and use it in GitHub Desktop.
Save irrationnelle/4ba25913fa1c42e68445 to your computer and use it in GitHub Desktop.
I just thought that this function need only current node's pointer which point NewNode, but NewNode also need current node's pointer which point former NextNode.
void SLL_InsertAfter(Node* Current, Node* NewNode)
{
Node* Tail = Current;
Tail->NextNode = NewNode;
}
@irrationnelle
Copy link
Author

void SLL_InsertAfter(Node* Current, Node* NewNode)
{
  NewNode->NextNode = Current->NextNode;
  Current->NextNode = NewNode;
}
void SLL_InsertAfter(Node* Current, Node* NewNode)
{
  // First, I have to substitute NewNode->NextNode = Currrent->NextNode !
  Node* Tail = Current; // useless Node declaration !
  Tail->NextNode = NewNode;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment