As we start coding and slowly learning about Data Structures(DS), we come across a very famous linear data structure which is known as a linked list. Linked lists and their related questions are quite popular in interviewers who love problem-solving.

A linked list is a common linear data structure. its elements are also known as **Node** are not stored at a contiguous location. The nodes are linked using pointers. Linked lists are popular as their size is not fixed like an array. Linked list’s each node contains a value and a pointer to the next node. The head pointer points to the first node, and the last node of the list points to null. When the linked list is empty, the head pointer points to null.

Pros:

1. Dynamically increase in size
2. Easy to insertion/deletion

Cons:

1. Accessing a random node is not allowed.
2. Additional memory space needs for each node in a linked list.
3. Not cache friendly.

```type Node struct {
prev *Node
next *Node
key interface{}
}

tail *Node
}```

Push method for a Linked List

```func (ll *LinkedList) Push(key interface{}) {
list := &Node{
key: key,
}
}

for ll.next != nil {
l = l.next
}
ll.tail = l
}```

```func (ll *LinkedList) Display() {
for list != nil {
fmt.Printf("%+v ->", list.key)
list = list.next
}
fmt.Println()
}

// normal display function
func Display(list *Node) {
for list != nil {
fmt.Printf("%v ->", list.key)
list = list.next
}
fmt.Println()
}```

```func (ll *LinkedList) Reverse() {
var next *Node
var previousNode *Node

for currentNode != nil {
next, currentNode.next = currentNode.next, previousNode
previousNode, currentNode = currentNode, next
}
}```

If you like, you can read the same article on my Personal Blog

Main function

```func main() {

fmt.Println("==============================")
fmt.Println("==============================")