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
Programming Articles - Page 914 of 3363
6K+ Views
The bootstrap confidence interval can be found by using the boot function. The bootstrapping is a method of finding inferential statistics with the help of sample data. It is done by drawing a large number of samples with replacement from the same values. Check out the Examples given below to understand how we can create a bootstrap confidence interval.Example 1Following snippet creates a sample data frame −x1
1K+ Views
To create intervals, we can use cut function with seq function and if we want to find the frequency based on these intervals then we just need to use table function along with cut function. We need to properly define the values for interval inside cut function. To understand how it can be done, check out the below Examples.Example 1Following snippet creates a sample data frame −x
2K+ Views
To find the unique pair combinations of an R data frame column values, we can use combn function along with unique function.For Example, if we have a data frame called df that contains a column say x then we can find the unique pair combinations of all column values by using the command given below −combn(unique(df$x),2,FUN=paste,collapse=' ')Example 1Following snippet creates a sample data frame −Grp
411 Views
To create a random sample by ignoring missing values in an R vector, we can use sample function and the negation of is.na with vector name.For Example, if we have a vector called X that contains some NAs then we can create a random sample of size 100 of X values by using the command given below −sample(X[!is.na(X)],100,replace=TRUE)Example 1To create a random sample by ignoring the missing values in an R vector, use the command given below −x1
4K+ Views
A matrix can be traversed in two ways. Row-mise traversal visits each row one by one starting from first row then second and so on till the last row. Elements in the row are returned from index 0 to the last index.In Column-wise traversal, elements are traversed from the first column to the last column in order.In 2D matrix M[i][j]. Index i is used for representing rows and index j is used for representing columns. For row-wise traversal, start fromi=0th row and 0
1K+ Views
Given an integer Number as input. The goal is to find the minimum number of steps or operations required to reduce the input Number to 1. Operations that can be performed will be-:If Number is even, then Divide it by 2.If Number is odd, then increment or decrement it by 1.ExamplesInput − Number=28Output − Minimum steps to reduce 28 to 1: 6Explanation−28 is even - divide by 2 = 1414 is even - divide by 2 = 77 is odd - increment by 1 = 88 is even - divide by 2 = 44 is even - divide by 2 = 22 ... Read More
15K+ Views
To check which value in NA in an R data frame, we can use apply function along with is.na function.For Example, if we have a data frame called df that contains some NA values then we can check which value is NA by using the command mentioned below −apply(df,2, function(x) is.na(x))This will return the data frame in logical form with TRUE and FALSE. Check out the below Examples to understand how it works.Example 1Following snippet creates a sample data frame −x1
6K+ Views
Given two integers Num1 and Num2 as input. The integers can be represented as fraction Num1/Num2. The goal is to reduce this fraction to its lowest form.Using GCD to find highest denominatorWe will calculate the greatest common divisor of both numbers.Divide both numbers by that gcdSet both variables as quotient after division.Lowest fraction will be Num1/Num2.ExamplesInput − Num1=22 Num2=10Output − Num1 = 11 Num2 = 5Lowest Fraction : 11/5Explanation− GCD of 22 and 10 is 2.22/2=11 and 10/2=5Lowest fraction is 11/5Input− Num1=36 Num2=40Output− Num1 = 9 Num2 = 10Lowest Fraction : 9/10Explanation − GCD of 36 and 40 is 4.40/4=10 and 36/4=9Lowest ... Read More
253 Views
Given an integer variable Number as input. Let us consider an array containing elements in the range 1 to Number in any order. If we perform an operation Number-1 times on an array such thatWe select two elements A and B from the arrayRemove A and B from arrayAdd sum of squares of A and B to the arrayWe will get a single integer value in the end; the goal is to find the maximum possible value for that element.Using Priority QueueIn order to maximize the end result, we will have to choose A and B such that they are ... Read More
295 Views
Given an integer variable Number as input. Let us consider an array containing elements in the range 1 to Number in sorted order. If we perform an operation on an array such that at each step the elements at odd positions are removed. Then the goal is to perform this operation N number of times till only a single element is left. Print that element at the end.Note-: The positioning of elements is such that the array at index 0 is at 1st position and so on.Test Cases for Number of elements in arrayInput Number=1, output = 1Input Number=2, output ... Read More