Programming Articles

Page 133 of 2544

How to remove dot and number at the end of the string in an R vector?

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

To remove dot and number at the end of the string, we can use gsub function. It will search for the pattern of dot and number at the end of the string in the vector then removal of the pattern can be done by using double quotes without space. After that the vector will be passed as shown in the below examples.Example1x1

Read More

C++ Program to Check Whether a given Binary Tree is a Full Binary Tree or not

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

Given a Binary Tree, the task is to check whether it is a Full Binary Tree or not. A Binary Tree is said to be a Full Binary Tree if every node has zero or two children.For ExampleInput-1Output:1Explanation: Every node except the leaf node has two children, so it is a full binary tree.Input-2: Output:0Explanation: Node 2 has only one child, so it is not a full binary tree.Approach to Solve this ProblemTo check whether a given binary tree is full or not, we can check recursively for the left subtree and right subtree.Input a given Binary Tree having nodes and its children.A ...

Read More

Double Base Palindrome in C++ Program

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

In this tutorial, we are going to write a program that checks whether the given number is a palindrome in two number systems.We have given a number and a base for another number system. We have to check whether the given number is a palindrome in the decimal number system and given number system.Let's see the steps to solve the problem.Initialize the number and number system base.Check whether the given number is a palindrome in the decimal number system or not.Convert the number into another number system in a string format.Check whether the converted number is palindrome or not.If the ...

Read More

How to remove column names from an R data frame?

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

There are situations when we might want to remove column names such as we want to manually replace the existing column names by new names or we simply don’t want to use them if we are very much familiar with the column characteristics. To remove the columns names we can simply set them to NULL as shown in the below examples.Example1Consider the below data frame −set.seed(357) x1

Read More

How to create the random sample by defining the probabilities for each unit in R?

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

The random sample can be created by using sample function, this random sample gives equal chance for each unit to be selected in the sample, hence it is called simple random sample. If we want to have a sample where each unit has different chance of being selected in the sample then we need to use the argument prob as shown in the below examples.Example1x1

Read More

C++ Program to find the smallest digit in a given number

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

Given a non-negative number, the task is to find its smallest digit.For exampleInput:N = 154870Output:0Explanation: In the given number '154870', the smallest digit is '0'.Approach to Solve this ProblemThe simplest approach to solve this problem is to extract the last digit in the given number using the remainder theorem. While traversing the number, we will check if the extracted digit is less than the last digit, then return the output.Take a number n as the input.An integer function smallest_digit(int n) takes 'n' as the input and returns the smallest digit in the given number.Now initialize min as the last digit of the ...

Read More

Double ended priority queue in C++ Program

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

In this tutorial, we are going to create a double-ended priority queue using the set in c++.Let's see the steps to create a double-ended queue.Create a struct with a name as you wish.Create a variable for the queue using the set.size method that returns the size of the queue.is_empty method that returns whether the queue is empty or not.insert method to insert a new element into the queue.get_start method that returns an element from the left side of the queue.get_end method that returns the element from the right side of the queue.delete_start method that deletes the first element from the ...

Read More

How to find the maximum value in an R data frame?

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

The maximum value is a part of summary statistics and we always need to understand the end limits of our data; therefore, it is highly required. If we have a data frame that contains numerical columns then the maximum value can be found by using max function and the data frame object name.Example1y1

Read More

Circle Sort in C++

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

Circle Sort is an interesting sorting algorithm to sort a given array of elements. The algorithm compares the elements of the array diametrically and once the elements in one part is sorted, then continuously sort the other end of the array diametrically.ExampleLet us visualize the circle sort for an array. Let us suppose we have an array with 6 elements.Input:N = 6arr [ ] = { 2, 1, 5, 8, 7, 9 }When we draw concentric circles for each array element, then it will appear as followsOutput:1 2 5 7 8 9Explanation: After sorting the elements in the array using Circle ...

Read More

Double the first element and move zero to end in C++ Program

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

In this tutorial, we are going to write a program that doubles the first element and moves all the zeroes to the end of the given array.We have to double a number when there are tow the same elements in adjacent indices. After that, we have to add a zero to the array.Move all the zeroes in the array to the end.ExampleLet's see the code.#include using namespace std; void moveZeroesToEnd(int arr[], int n) {    int count = 0;    for (int i = 0; i < n; i++) {       if (arr[i] != 0) {   ...

Read More
Showing 1321–1330 of 25,433 articles
« Prev 1 131 132 133 134 135 2544 Next »
Advertisements