
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 26504 Articles for Server Side Programming

289 Views
To find the row products for each row in an R data frame, we can use rowProds function of matrixStats package but we need to read the data frame as a matrix.For Example, if we have a data frame called df then we can find the row products for each row in df by using the command given below −rowProds(as.matrix(df))Example 1Following snippet creates a sample data frame −x1

142 Views
To draw concentric circles, we can use draw.circle function of plotrix package where we can put lwd argument but firstly we would need to create a blank graph with plot function as shown below.For Example, we can create three concentric circles at position X=5 and Y=5 having radius of 1, 2, and 3 by using the below command −draw.circle(5, 5, c(1.5, 1, 0.5), col=c("yellow", "green", "orange"), lwd=2)ExampleConsider the following snippet −plot(1:10, type="n")OutputIf you execute the above given snippet, it generates the following Output −Add the following code to the above snippet −plot(1:10, type="n") library(plotrix) draw.circle(5, 5, c(1.5, 1, 0.5), col=c("yellow", ... Read More

360 Views
To create matrix diagram, we can use corrplot function of corrplot function. For this purpose, we would need to set is.corr argument to FALSE so that the matrix values will be plotted in the diagram. Otherwise, the corrplot function requires correlation matrix instead of a matrix.Check out the Example given below to understand how it works.ExampleFollowing snippet creates a sample matrix −M

256 Views
To create a random sample by excluding missing values of a data frame column, we can use sample function and the negation of is.na with the column of the data frame.For Example, if we have a data frame called df that contains a column X which has some NAs then we can create a random sample of size 100 of X values by using the following command −sample(df$X[!is.na(df$X)],100,replace=TRUE).Example 1Following is the code snippet to create dataframe −x

1K+ Views
To create line chart for mean covered with minimum and maximum in R, we first need to create columns for row means, row minimum, and row maximum after that geom_line function can be used along with geom_ribbon function of ggplot2 package as shown in the below example.ExampleFollowing snippet creates a sample dataframe.x

506 Views
Suppose we have a value n, we have to find the number of pairs (a, b) [a < b], that exist such that the equation a*x + b*y = n, has at least one solution.So, if the input is like n = 4, then the output will be 2 because the valid pairs are (1, 2) and (1, 3).To solve this, we will follow these steps −Define a function divisors_gen() . This will take ndivs := a list of lists of size n+1. And each inner list is holding 1divs[0] := a list with only one element 0for i in ... Read More

125 Views
Suppose we have a number n. We have to find smallest number m, such that factorial of m has at least n number of 0s.So, if the input is like n = 2, then the output will be 10 because 10! = 3628800 and 9! = 362880, minimum number with 2 zeros is 10.To solve this, we will follow these steps −Define a function count_fives() . This will take ncnt := 0while n > 0, don := floor of (n / 5)cnt := cnt + nreturn cntFrom the main method, do the following −left := 1right := 5^24while right - ... Read More

320 Views
Suppose we have k number of candies. We have to distribute them among children. Now there are some rulesith child will get i^2 number of candiesany children at index i will not get any candy until all children from index 1 to i-i are servedIf ith children does not get i^2 number of candies, then that is not a valid serve.So, if the input is like k = 20, then the output will be 3 because, first one will get 1, second one will get 2^2 = 4, third one will get 3^2 = 9, but fourth one needs 4^2 ... Read More

472 Views
Suppose we have two numbers n and m. We have to find the remainder after dividing n number of 1s by m.So, if the input is like n = 4 m = 27, then the output will be 4, because 1111 mod 27 = 4.To solve this, we will follow these steps −Define a function util() . This will take x, n, my := 1while n > 0, doif n is odd, theny := (y * x) mod mx := (x * x) mod mn := floor of n/2return yFrom the main method return floor of (util(10, n, 9 * ... Read More
Program to find number of pairs from N natural numbers whose sum values are divisible by k in Python

277 Views
Suppose we have a number n and another value k, consider we have an array A with first N natural numbers, we have to find the total number of pairs of elements A[i] and A[j] from A, such that, i < j and their sum is divisible by k.So, if the input is like n = 10 k = 4, then the output will be 10 because there are 10 pairs whose sum is divisible by 4. [(1, 3), (1, 7), (2, 6), (2, 10), (3, 5), (3, 9), (4, 8), (5, 7), (6, 10), (7, 9)]To solve this, we ... Read More