Skip to content

Instantly share code, notes, and snippets.

@AahanSingh
Created July 3, 2021 11:20
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 AahanSingh/5633eb294a56b0844b8e6546ae37aba9 to your computer and use it in GitHub Desktop.
Save AahanSingh/5633eb294a56b0844b8e6546ae37aba9 to your computer and use it in GitHub Desktop.
DLList InsertAtEnd
func InsertAtEnd(head **DLNode, x int) {
tmp := &DLNode{Data: x}
fmt.Println("Inserting", tmp, "at the end")
if *head == nil {
*head = tmp
} else {
p := *head
for ; p.Next != nil; p = p.Next {
}
p.Next = tmp
tmp.Prev = p
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment