Articles on Trending Technologies

Technical articles with clear explanations and examples

How to create a frequency table in R that includes zero frequency for value that are not available?

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

When we use table function in R, the output shows the frequency of values that are available in the vector or in column of the data frame. If we want to create the table with the frequency zero for values that are not part of the vector or the column then first we need to convert them to factor first and then use the table function.Example1x1

Read More

Write a Golang program to find duplicate elements in a given range

Kiran P
Kiran P
Updated on 11-Mar-2026 762 Views

We can solve this problem in two different ways. Let’s check the first method.Method 1: ExamplesInput Array = [1, 2, 3, 4, 4] => Range is from 1 to 5 but 4 is a duplicate element in this range.Approach to solve this problemStep 1: Define a method that accepts an array.Step 2: Declare a visited map.Step 3: Iterate the given array. If the element exists in the visited map, then return that element.Step 4: Else, return -1.Programpackage main import "fmt" func duplicateInArray(arr []int) int{    visited := make(map[int]bool, 0)    for i:=0; i Range is from 1 to 5 but 4 is ...

Read More

How to create a column with largest size string value in rows in an R data frame?

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

To create a column with largest size string value in rows, we can use apply function and define the size of the string for the largest value by creating a function as shown in the below examples. If the number of characters in all the columns are same or there exists some ties then the output will be the first one.Example1y1

Read More

How to multiply all values in a list by a number in R?

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

To multiply all values in a list by a number, we can use lapply function. Inside the lapply function we would need to supply multiplication sign that is * with the list name and the number by which we want to multiple all the list values. For example, if we have a list called LIST and we want to multiply each value in LIST by 2 then it can be done by using the command lapply(LIST,"*",2).Example1List1

Read More

Write a Golang program to find odd and even numbers using bit operation

Kiran P
Kiran P
Updated on 11-Mar-2026 636 Views

ExamplesInput num = 5 => 101 & 1 = 001 => True, i.e., Odd; else num would be Even.Approach to solve this problemStep 1: Define a method that accepts a number.Step 2: Perform & operation with that number.Step 3: If the & operator returns a non-zero value, then that number would be odd.Step 4: Else, the number would be even.Programpackage main import "fmt" func oddEven(num int){    if num & 1 != 0 {       fmt.Println("ODD")    } else {       fmt.Println("EVEN")    } } func main(){    oddEven(13)    oddEven(50)    oddEven(0) }OutputODD EVEN EVEN

Read More

How to find the sum of rows, columns, and total in a matrix in R?

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

To find the sum of row, columns, and total in a matrix can be simply done by using the functions rowSums, colSums, and sum respectively. The row sums, column sums, and total are mostly used comparative analysis tools such as analysis of variance, chi−square testing etc.Example1M1

Read More

Delete leaf nodes with value as x in C++ Program

Hafeezul Kareem
Hafeezul Kareem
Updated on 11-Mar-2026 1K+ Views

In this tutorial, we are going to learn how to delete the leaf nodes from a tree with the given value.Let's see the steps to solve the problem.Write a struct Node for a binary tree.Write a function to traverse (inorder, preorder, postorder) through the tree and print all data.Initialize the tree by creating nodes with the struct.Initialize the x value.Write a function to delete the leaf nodes with the given value. It accepts two arguments root node and x value.If the root is a null return.Replace the left node of the root with a new root after deletion.Same with the ...

Read More

Write a program in C++ to find the most frequent element in a given array of integers

Dev Prakash Sharma
Dev Prakash Sharma
Updated on 11-Mar-2026 4K+ Views

Let’s suppose we have an array of integers of size N. The task is to find the most frequent element present in the given array of integers. For example, Input-1 −N = 8 A[ ] = {1, 2, 4, 3, 3, 1, 1, 5}Output −1Explanation − In the given array of integers, the most appearing number is ‘1’. Thus the output is ‘1’.Input-2 −N = 6 A[ ] = {1, 4, 4, 4, 1, 1}Output-a −1Output-b −4Explanation: In the given array of integers, the most appearing number is ‘1’ and ‘4’. Thus we can return the output to any one ...

Read More

How to use column index instead of column name while using group_by of dplyr in R?

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

When we use group_by function of dplyr package, we need to pass the column name(s) that are categorical in nature. If we want to use the index of the same column(s) then group_by_at function needs to be used, where we can pass the column index as the argument.Example1y1

Read More

Delete leaf nodes with value k in C++ program

Hafeezul Kareem
Hafeezul Kareem
Updated on 11-Mar-2026 244 Views

In this tutorial, we are going to learn how to delete the leaf nodes from a tree with the given value.Let's see the steps to solve the problem.Write a struct Node for a binary tree.Write a function to traverse (inorder, preorder, postorder) through the tree and print all data.Initialize the tree by creating nodes with the struct.Initialize the x value.Write a function to delete the leaf nodes with the given value. It accepts two arguments root node and k value.If the root is a null return.Replace the left node of the root with a new root after deletion.Same with the ...

Read More
Showing 25701–25710 of 61,299 articles
Advertisements