-
-
Save AahanSingh/5633eb294a56b0844b8e6546ae37aba9 to your computer and use it in GitHub Desktop.
DLList InsertAtEnd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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