Skip to content

Commit 4058024

Browse files
committed
add description
1 parent 834b0bd commit 4058024

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Linked List/double_linked_list.go

+13
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
// Implementation of a doubly linked list in Go
2+
/*
3+
In this implementation, we define a Node struct that contains the data as well as pointers to the previous and next nodes.
4+
We also define a LinkedList struct that contains a pointer to the head and tail nodes.
5+
6+
The AddNode method adds a new node to the end of the list. If the list is empty, the new node is set as both the head and tail.
7+
Otherwise, the new node is added after the current tail, and the current tail is set as the previous node of the new node.
8+
Finally, the new node is set as the new tail.
9+
10+
The PrintList method traverses the list from the head node and prints the data of each node.
11+
12+
In the main function, we create a new doubly linked list, add some nodes to it, and print the list.
13+
*/
114
package main
215

316
import "fmt"

0 commit comments

Comments
 (0)