- Learn Data Structures and Algorithms with Golang
- Bhagvan Kommadi
- 109字
- 2021-06-24 15:37:47
Doubly linked list
In a doubly linked list, all nodes have a pointer to the node they are connected to, on either side of them, in the list. This means that each node is connected to two nodes, and we can traverse forward through to the next node or backward through to the previous node. Doubly linked lists allow insertion, deletion and, obviously, traversing operations. The node class definition is presented in the following code example:
// Node class
type Node struct {
property int
nextNode *Node
previousNode *Node
}
The following sections explain doubly linked list methods, such as the NodeBetweenValues, AddToHead, AddAfter, AddToEnd, and main methods.