Skip to content

Instantly share code, notes, and snippets.

@AahanSingh
Created July 3, 2021 10:54
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/cfc5c7db3eb4ba4383c74b8d2db1ca4b to your computer and use it in GitHub Desktop.
Save AahanSingh/cfc5c7db3eb4ba4383c74b8d2db1ca4b to your computer and use it in GitHub Desktop.
DL List traversal and length
func DisplayList(head *DLNode) {
fmt.Printf("The list is: ")
for ; head != nil; head = head.Next {
fmt.Print(" -> ", head)
}
fmt.Println()
fmt.Println()
}
func Length(head *DLNode) int {
len := 0
for ; head != nil; head = head.Next {
len++
}
fmt.Println("Length = ", len)
return len
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment