Skip to content

Instantly share code, notes, and snippets.

@AahanSingh
Created Jul 4, 2021
Embed
What would you like to do?
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