Articles on Trending Technologies

Technical articles with clear explanations and examples

Nth Catalan Number in Go Lang

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

Catalan Numbers are sequences of natural numbers that gives the number of BST (Binary Search Tree) possible with n Values. So, the Catalan number is a full binary tree with n+1 leaves.Some applications of Catalan Numbers are counting the pairs of nested parentheses, valid mountain ranges etc.For n = 5, C = (C(0) * C(4)) + (C(1) * C(3)) + (C(2) * C(2)) + (C(3) * C(1)) + (C(4)* C(0))Thus, we can see that Catalan numbers are in the form of a recursive relation, i.e., for the nth term, the Catalan number Cn is,             ...

Read More

How to plot matrix columns as lines in base R?

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

To plot matrix columns as lines in base R, we can use matplot function but we need to read the matrix as a data frame using as.data.frame function and for creating lines the type argument will be used. For example, if we have a matrix called M then the columns of M can be plotted as lines using the command matplot(as.data.frame(M),type="l").Consider the below data frame −ExampleM

Read More

Determine the position of the third person on regular N sided polygon in C++ Program

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

In this tutorial, we are going to learn how to find the position of a third person on a regular N-sided polygon.We have given a regular N-sided polygon. And there are two persons on two different points already. Our task is to find the third point to place the third person such that the distance between the first two persons and the third person is minimized.Let's see the steps to solve the problem.Initialize the N and two points A and B.Initialize the position of the third person, and the minimum sum to find the position.Iterate from 1 to N.If the ...

Read More

Diagonal of a Regular Heptagon in C++ Program

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

In this tutorial, we are going to learn how to find the diagonal of a regular heptagon.We have to find the length of the diagonal of the regular heptagon using the given side. The length of the diagonal of a regular heptagon is 1.802 * s where s is the side of the heptagon.ExampleLet's see the code.#include using namespace std; float heptagonDiagonal(float s) {    if (s < 0) {       return -1;    }    return 1.802 * s; } int main() {    float s = 7;    cout

Read More

Write a program in C++ to replace all the 0's with 5 in a given number

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

Given an integer N, the task is to replace all the 0’s that appear in the number with ‘5’. However, the number with leading ‘0’ cannot be replaced with ‘5’ as it remains unchanged. For example, Input-1 −N= 1007Output −1557Explanation − The given number has 2 zeros which when replaced by ‘5’ results in the output as 1557.Input-2 −N = 00105Output −155Explanation − Since the given number starts with the leading ‘0’ which can be ignored and the output after replacing the 0 in the middle with ‘5’ results the output as 155.Approach to Solve this ProblemTo replace all the ...

Read More

How to save a csv and read using fread in R?

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

To save a csv file, we can use write.csv function in R and if we want to read it using fread then fread function will be used with the name of the csv file. The benefit of reading the csv file with fread function is that there will be a variable added to the original csv file which contains the id as integers starting from 1 to the length of column values.Consider the below data frame −Examplex

Read More

Diagonal of a Regular Pentagon in C++ Program

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

In this tutorial, we are going to learn how to find the diagonal of a regular pentagon.We have to find the length of the diagonal of the regular pentagon using the given side. The length of the diagonal of a regular pentagon is 1.22 * s where s is the side of the pentagon.ExampleLet's see the code.#include using namespace std; float pentagonDiagonal(float s) {    if (s < 0) {       return -1;    }    return 1.22 * s; } int main() {    float s = 7;    cout

Read More

Reverse Vowels of a string in C++

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

Given a string, the task is to reverse all the vowels present in the given string. For example, Input-1 −a = “tutor”Output −toturExplanation − Reversing the string “tutor” will generate the output as “totur.Input-2 −a = “mathematics”Output −mithametacsExplanation − Reversing the string “mathematics” will generate the output as “mithametacs”.Approach to solve this problemGiven a string, we have to reverse all the vowels present in it. There are several approaches to solve this particular problem but we have to solve this in linear time O(n).Thus, the better method to solve this problem is to use the Two-Pointer approach in which we ...

Read More

How to hide NA values in an R matrix?

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

The hiding of NA values does not mean removal of NA values. If we have some NA values in an R matrix then we can hide them using blanks with double quotes. For example, suppose we have a matrix called M that contains some NA values then M can be printed by hiding NA value using print.table(M,na.print="")ExampleM1

Read More

How to fill NA values with previous values in an R data frame column?

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

To fill NA values with next and previous values, we can use na.locf function of zoo package with fromLast = TRUE. This is the situation of a column as shown below −x 0 NA NA 1 1 NA 0 1The output after filling NA values with next and previous values will be −x 0 0 0 1 1 1 0 1Consider the below data frame −Examplex1

Read More
Showing 25411–25420 of 61,297 articles
Advertisements