Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

1,016 Articles Published

Articles by Rishikesh Kumar Rishi

Page 8 of 102

Golang Program to update the last node value in a linked list.

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 11-Mar-2026 335 Views

ExampleApproach to solve this problemStep 1 − Define a method that accepts the head of a linked list.Step 2 − If head == nil, return the head.Step 3 − Else, update the last node value to 41.Examplepackage main import "fmt" type Node struct {    value int    next *Node } func NewNode(value int, next *Node) *Node{    var n Node    n.value = value    n.next = next    return &n } func TraverseLinkedList(head *Node){    temp := head    for temp != nil {       fmt.Printf("%d ", temp.value)       temp = temp.next    } ...

Read More

Golang Program to insert a new node after the Kth node.

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 11-Mar-2026 181 Views

ExamplesAdd node 15 after 10 value node.Approach to solve this problemStep 1 − Define a method that accepts the head of a linked list.Step 2 − If head == nil, return the head.Step 3 − Iterate the given linked list.Step 4 − If temp.value is 10, then add the node 15 as the next node.Step 5 − If node value 10 is not found, return the head without adding any node.Examplepackage main import "fmt" type Node struct {    value int    next *Node } func NewNode(value int, next *Node) *Node{    var n Node    n.value = value   ...

Read More

Golang program to delete the node after the Kth node.

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 11-Mar-2026 174 Views

ExamplesDelete node after 10 value node.Approach to solve this problemStep 1 − Define a method that accepts the head of a linked list.Step 2 − If head == nil, return the head.Step 3 − Iterate the given linked list.Step 4 − If temp.value is 10, then override that node’s next value with its next node’s next value.Step 5 − If node value 10 is not found, return the head without deleting any node.Examplepackage main import "fmt" type Node struct {    value int    next *Node } func NewNode(value int, next *Node) *Node{    var n Node    n.value = ...

Read More

Golang Program to update the node value after the Kth node.

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 11-Mar-2026 169 Views

ExamplesUpdate node after k=10 value nodeApproach to solve this problemStep 1 − Define a method that accepts the head of a linked list.Step 2 − If head == nil, return the head.Step 3 − Iterate the given linked list.Step 4 − If temp.value is 10, then update temp.next.value=data.Step 5 − If node value 10 is not found, return the head without updating any node.Examplepackage main import "fmt" type Node struct {    value int    next *Node } func NewNode(value int, next *Node) *Node{    var n Node    n.value = value    n.next = next    return &n } ...

Read More

Golang Program to update the node value after the Kth node (When K is not in the linked list).

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 11-Mar-2026 142 Views

ExamplesUpdate node after k=50 value nodeApproach to solve this problemStep 1 − Define a method that accepts the head of a linked list.Step 2 − If head == nil, return the head.Step 3 − Iterate the given linked list.Step 4 − If node value 10 is not found, return the head without updating any node.Examplepackage main import "fmt" type Node struct {    value int    next *Node } func NewNode(value int, next *Node) *Node{    var n Node    n.value = value    n.next = next    return &n } func TraverseLinkedList(head *Node){    temp := head    for ...

Read More

Golang Program to update the ith index node value, when index is at 0 index.

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 11-Mar-2026 162 Views

ExamplesApproach to solve this problemStep 1 − Define a method that accepts the head of a linked list.Step 2 − If head == nil, return the head.Step 3 − Initialize the index as i := 0.Step 4 − Iterate the given linked list from its head.Step 5 − If index i matches with given index (to be updated), then update that node.Step 6 − Else, return the head.Examplepackage main import "fmt" type Node struct {    value int    next *Node } func NewNode(value int, next *Node) *Node{    var n Node    n.value = value    n.next = next ...

Read More

Golang Program to update the ith index node value, when index is at the last index.

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 11-Mar-2026 158 Views

ExampleApproach to solve this problemStep 1 − Define a method that accepts the head of a linked list.Step 2 − If head == nil, return the head.Step 3 − Initialize the index as i := 0.Step 4 − Iterate the given linked list from its head.Step 5 − If index i matches with the given index (to be updated), then update that node.Step 6 − Else, return head.Examplepackage main import "fmt" type Node struct {    value int    next *Node } func NewNode(value int, next *Node) *Node{    var n Node    n.value = value    n.next = next ...

Read More

Golang Program to delete the ith index node, when the index is at 0th position in the linked list.

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 11-Mar-2026 164 Views

ExamplesApproach to solve this problemStep 1 − Define a method that accepts head of the linked list.Step 2 − If head == nil, return the head.Step 3 − When index == 0, then return head.nextStep 4 − Else, Iterate given linked list from head.Step 5 − If index i matches with given index(to be delete) then delete that node.next, break the loop.Step 6 − Return, at the end of loop.Examplepackage main import "fmt" type Node struct {    value int    next *Node } func NewNode(value int, next *Node) *Node{    var n Node    n.value = value    n.next ...

Read More

Golang Program to insert a node at the ith index node, when the index is at the 0th position in the linked list.

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 11-Mar-2026 448 Views

ExamplesApproach to solve this problemStep 1 − Define a method that accepts the head of a linked list.Step 2 − If head == nil, create a new node and make it head and return it as the new head.Step 3 − When index == 0, then update the head.Step 4 − Iterate the given linked list from its head. Also, initialize preNode that will keep the store address of the previous node.Step 5 − If index i matches with the given index, then then delete that node.next, break the loop.Step 6 − Return, at the end of loop.Examplepackage main import ...

Read More

Golang program to insert a node at the ith index node, when the index is at the last position in the linked list.

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 11-Mar-2026 205 Views

ExamplesExampleApproach to solve this problempackage main import "fmt" type Node struct {    value int    next *Node } func NewNode(value int, next *Node) *Node{    var n Node    n.value = value    n.next = next    return &n } func TraverseLinkedList(head *Node){    temp := head    for temp != nil {       fmt.Printf("%d ", temp.value)       temp = temp.next    }    fmt.Println() } func InsertNodeAtIthIndex(head *Node, index, data int) *Node{    if head == nil{       head = NewNode(data, nil)       return head    }    if index ...

Read More
Showing 71–80 of 1,016 articles
« Prev 1 6 7 8 9 10 102 Next »
Advertisements