Programming Articles

Page 1159 of 2547

How to create a dummy variable in R?

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

A dummy variable is a type of variable that takes a value of 1 if the value for which the dummy variable is created exists in the data frame, otherwise it takes 0. Therefore, if we have a one binary variable in a data frame then there will be two dummy variables for the same. To create a dummy variable, we can use model.matrix function as shown in the below examples.Consider the below data frame −ExampleTemp

Read More

Divide large number represented as string in C++ Program

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

In this tutorial, we are going to learn how to divide a large number that is represented as a string.We have given a large number in string format and a divisor. Our program should find a reminder.First, we will find a part of the given number that is greater than the dividend. And then we will add the remaining digits one by one to the divisor.Let's see the steps to solve the problem.Initialize the large number along with a divisor.Iterate over the given number until we extract the part that is greater than the divisor.Now, iterate from where we left ...

Read More

How to convert NaN to NA in an R data frame?

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

To convert NaN to NA in an R data frame, we can set the NaN values to NA values by using single square brackets. Firstly, we would need to access the column that contains NaN values then NaN values will be accessed using is.nan then we can set those values to NA as shown in the below examples.Consider the below data frame −Examplex1

Read More

How to extract the closest value to a certain value in each category in an R data frame?

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

In Data Analysis, we often deal with the comparison of values and this comparison could be also done after finding the closest value to a certain value that might be threshold. For this purpose, we can use filter function of dplyr package along with abs and min function, the abs and min function are required to create the formula for finding the closest value.Consider the below data frame −ExampleCategory

Read More

Divide the given linked list in two lists of size ratio p:q in C++ Program

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

In this tutorial, we are going to write a program that divides the given linked list into a p:q ratioIt's a straightforward program. Let's see the steps to solve the problem.Create a struct for the linked list node.Initialize the linked list with dummy data.Initialize the p:q ratio.Find the length of the linked list.If the length of the linked list is less than p + q, then it's not possible to divide the linked into a p:q ratio.Else iterate the linked list until p.After the p iterations, remove the link and create a new head for the second linked list.Now, print ...

Read More

Divisibility by 12 for a large number in C++ Program

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

In this tutorial, we are going to write a program that checks whether the given large number in string format is divisible by 12 or not.We are going to use a little bit of math to solve this problem. If the number is divisible by 3 and 4, then the number will divisible by 12.A number is divisible by 3 if the sum of its digits is divisible by 3.A number is divisible by 4 if the last two digits of the number are divisible by 4.We are going to utilize the above statements and complete the program.ExampleLet's see the ...

Read More

How to replace a complete column in an R data frame?

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

To replace a complete column in an R data frame, we can set the original one to new values by using delta operator. For example, if we have a data frame called df that contains a column x which 500 has values from normal distribution then to replace it with the normal distribution having a mean of 25 can be done as df$x

Read More

Binary Tree Tilt in C++

Dev Prakash Sharma
Dev Prakash Sharma
Updated on 11-Mar-2026 431 Views

Let us consider that we have the root node of a binary tree; the task is to find and return the sum of tilt of every node.The tilt of a binary tree is nothing but constructing the binary tree by finding the absolute difference of child nodes in the left subtree and the right subtree in each level. At some particular level, the nodes which don't have any child nodes, we simply tilt by replacing that node with zero.ExampleInputOutput: 15Explanation: Finding the tilt at every level of the given binary tree, The tilt of node 3 = 0The tilt of node ...

Read More

Divisible by 37 for large numbers in C++ Program

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

In this tutorial, we are going to write a program that checks whether the given large number is divisible by 37 or not.We are going to use a little bit of math here. Let's see the steps to solve the problem.Initialize the number.If the length of the given number is not divisible by 3, then add zeroes at the beginning of the number to make length is divisible by 3.Divide the number into 3 digits groups and add them.If the resultant sum is divisible by 37, then the given number is divisible by 37.If the resultant sum is 4 digits ...

Read More

Check if a Tree is Isomorphic or not in C++

Dev Prakash Sharma
Dev Prakash Sharma
Updated on 11-Mar-2026 469 Views

In a binary tree, each node contains two children, i.e., left child and right child. Let us suppose we have two binary trees and the task is to check if one of the tree can be obtained by flipping another tree by left of it or not.A Tree is Isomorphic if it can be obtained by flipping the other tree in its left side.For ExampleInput-1Output: IsomorphicExplanation: The given Tree-2 can be obtained by flipping the Tree-1 in the left side, thus the Tree is isomorphic.Approach to Solve this ProblemA recursive approach to solve this particular problem is that a Boolean function will ...

Read More
Showing 11581–11590 of 25,466 articles
Advertisements