# Category Archives: Mathematical

Given a number n, write an efficient function to print all prime factors of n. For example, if the input number is 12, then output… Read More
Given a number n, write an efficient function to print all prime factors of n. For example, if the input number is 12, then output… Read More
There are two vessels of capacities 'a' and 'b' respectively. We have infinite water supply. Give an efficient algorithm to make exactly 1 litre of water in one of the vessels.
Team : Transportation Location :Hyderabad Round 1 (Online Test) Q1. Find the kth largest value in a BST Q2. Swap the alternate nodes in a singly linked… Read More
The value of Exponential Function e^x can be expressed using following Taylor Series. e^x = 1 + x/1! + x^2/2! + x^3/3! + ...... How… Read More
Write code to convert a given number into words. For example, if “1234” is given as input, output should be “one thousand two hundred thirty… Read More
There are some glasses with equal capacity as 1 litre. The glasses are kept as follows:   1 2 3 4 5 6 7 8 9… Read More
An array of size n is given. The array contains digits from 0 to 9. Generate the largest number using the digits in the array… Read More
Given a stream of numbers, generate a random number from the stream. You are allowed to use only O(1) space and the input is in… Read More
Pascal’s triangle is a triangular array of the binomial coefficients. Write a function that takes an integer value n as input and prints first n… Read More
We know the Pascal’s Identity very well, i.e. ncr = n-1cr + n-1cr-1 A curious reader might have observed that Pascal’s Identity is instrumental in… Read More
Reservoir sampling is a family of randomized algorithms for randomly choosing k samples from a list of n items, where n is either a very… Read More
Write a function that takes two parameters n and k and returns the value of Binomial Coefficient C(n, k). Example:   Input: n = 4 and k… Read More
Given an unsorted array of positive integers, find the number of triangles that can be formed with three different array elements as three sides of… Read More
Given an array, write a program to generate a random permutation of array elements. This question is also asked as “shuffle a deck of cards”… Read More