Skip to content

Instantly share code, notes, and snippets.

@AahanSingh
Created July 4, 2021 05:00
Show Gist options
  • Save AahanSingh/4f35a093363f03a8aca44651f6f13d28 to your computer and use it in GitHub Desktop.
Save AahanSingh/4f35a093363f03a8aca44651f6f13d28 to your computer and use it in GitHub Desktop.
DL List deleting the first node
func DeleteFirst(head **DLNode) {
if *head == nil {
fmt.Println("\nList empty")
return
}
fmt.Println("\nDeleting first Node: ", *head)
// We change head to point to the next Node
*head = (**head).Next
// To remove all references to the deleted node, set the Prev pointer of head to nil
if *head != nil {
(**head).Prev = nil
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment