Skip to content

Instantly share code, notes, and snippets.

@easleyschool
Created October 10, 2019 04:26
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 easleyschool/8156faf75d92c241507f96b0c5338222 to your computer and use it in GitHub Desktop.
Save easleyschool/8156faf75d92c241507f96b0c5338222 to your computer and use it in GitHub Desktop.
/*
Adds an element at the front
@param: n a pointer to the node to add
@return: the position where node is added
*/
int LinkedList :: addAtFront(node *n) {
int i = 0;
//making the next of the new Node point to Head
n->next = head;
//making the new Node as Head
head = n;
i++;
//returning the position where Node is added
return i;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment