Programming Articles

Page 1146 of 2547

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 189 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

How to calculate the z score for grouped data in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 725 Views

To calculate the z score for grouped data, we can use ave function and scale function. For example, if we have a data frame called df that contains a grouping coloumn say GROUP and a numerical column say Response then we can use the below command to calculate the z score for this data −ave(df$Response,df$GROUP,FUN=scale)ExampleConsider the below data frame −grp

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 470 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 223 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

How to display tick marks on upper as well as right side of the plot using ggplot2 in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 851 Views

To display tick marks on upper as well as right side of the plot, we can create duplicate axes for X as well Y by using scale_x_continuous and scale_y_continuous functions. The argument that will help us in this case is sec.axis and we need to set it to dup_axis as scale_x_continuous(sec.axis=dup_axis()) and scale_y_continuous(sec.axis=dup_axis()). Check out the below example to understand how it can be done.ExampleConsider the below data frame −x

Read More

Golang Program to create a doubly linked list and traverse forward.

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

A doubly linked list node contains three items, where two items point to the next and previous nodes, and the third item contains the value of that node.ExampleApproachStep 1 − Define a method that accepts the head of a doubly linked list.Step 2 − Initialize temp:=head.Step 3 − Iterate temp until it becomes nil.Step 4 − Print temp.value.Examplepackage main import "fmt" type Node struct {    prev *Node    value int    next *Node } func CreateNewNode(value int) *Node{    var node Node    node.next = nil    node.value = value    node.prev = nil    return &node } func ...

Read More

How to select columns in R without missing values?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 3K+ Views

There are two easy methods to select columns of an R data frame without missing values, first one results in a vector and other returns a matrix. For example, if we have a data frame called df then the first method can be used as df[,colSums(is.na(df))==0] and the second method will be used as t(na.omit(t(df))).ExampleConsider the below data frame −df1

Read More

Golang program to create an integer array that takes inputs from users.

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 11-Mar-2026 4K+ Views

ExampleApproachAsk the user to enter the size of array.Make an integer array of given size.Ask the user to enter elements.At the end, print the array.Examplepackage main import (    "fmt" ) func main(){    fmt.Printf("Enter size of your array: ")    var size int    fmt.Scanln(&size)    var arr = make([]int, size)    for i:=0; i

Read More

How to display mean in a boxplot with cross sign in base R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 394 Views

To display mean in a boxplot with cross sign in base R, we can use the points function and pass the mean with pch = 4 that represents a star, also we can change the color to highlight the mean using col argument and the size of the start can be changed using lwd argument as shown in the below examples.Examplex

Read More

Golang program to traverse a given input array, with Boolean flag, using arrays and struct.

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

ExampleApproachAsk the user to enter the size of array.Make a string array of given size.Ask the user to enter elements.At the end, print the array.Examplepackage main import "fmt" func main(){    arr := []int{10, 20, 30, 60, 40, 50}    boolArr := []bool{true, false, true, false, true, false}    fmt.Println("Input Array is: ", arr)    fmt.Println("Input Boolean Array is: ", boolArr)    visitedArray := []struct{       i int       b bool    }{       {10, true},       {20, false},       {30, true},       {60, false},       {40, true},       {50, false},    }    fmt.Println("Boolean array using struct: ", visitedArray) }OutputInput Array is: [10 20 30 60 40 50] Input Boolean Array is: [true false true false true false] Boolean array using struct: [{10 true} {20 false} {30 true} {60 false} {40 true} {50 false}]

Read More
Showing 11451–11460 of 25,466 articles
Advertisements