Skip to content

Instantly share code, notes, and snippets.

@easleyschool
Created October 10, 2019 04:42
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/bb05af904ab1a14fb1aa2f577402b150 to your computer and use it in GitHub Desktop.
Save easleyschool/bb05af904ab1a14fb1aa2f577402b150 to your computer and use it in GitHub Desktop.
/*
Searching for an Element in the List
@param: element in the list to look for
@returns: a pointer to the found node.
*/
node* LinkedList :: search(int x) {
node *ptr = head;
//until we reach the end or we find a Node with data x, we will keep moving
while( ptr != NULL && ptr->data != x ) {
ptr = ptr->next;
}
return ptr;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment