## Divide with power of 2 without using pow() or / operator

Objective: Given a number n and k, Calculate n / k2 without using pow() or / operator. Example: N = 48, k = 4 N/k2 = 3 Approach: Bit Manipulation Right shift the number...

@tutorialhorizon

Objective: Given a number n and k, Calculate n / k2 without using pow() or / operator. Example: N = 48, k = 4 N/k2 = 3 Approach: Bit Manipulation Right shift the number...

Objective– Given the numbers 1 to 1000, what is the minimum number of guesses needed to find a specific number if you are given the hint “higher” or “lower” for each guesses you make....

Objective – Given three vertices coordinates or (X, Y) coordinates, write a program to find the area of a triangle. Example: Approach: Given the coordinates of the three vertices of any triangle are (X1,...

Algorithms – Java Program to find if Triangle can be formed using given 3 sides Objective– Given 3 side lengths, write a program to find out if using these 3 sides, a triangle can...

Objective – Given three sides of triangle, write a program to find the area of a triangle. Heron’s Formula for finding area of triangle: First find the semi parameter of a triangle using formula,...

Objective: Given a number, write a program to find factorial of that number. What is Factorial Number? In mathematics, the factorial of a non-negative integer n, denoted by n!, is the product of all positive integers less than or equal to n. The value of...

Objective: Given a number, find the sum of all of the digits in the number. Example: Number = 3045 Sum = 3+0+4+5 = 12 Number = 231 Sum = 2+3+1 = 7 Approach: Initialize...

Objective: Given an integer check whether it is a perfect square. Example: number = 37 Output: false number = 49 Output: true This is fun puzzle which is asked in the interview. Approach: Say number...

Objective: Given two numbers ‘k’ and ‘n’. Write an algorithm to calculate kn. Example: k = 4, n = 5 kn = 45 = 1024 k = 2, n = 3 kn = 23 =...

Objective: Write Given two integers ‘number’ and ‘divisor’, Write an algorithm to find the remainder if ‘number’ is divided by ‘divisor’. Condition: You are not allowed to use modulo or % operator. Example: num =...

Objective: Write an algorithm to swap two numbers without using extra variable. This is fun puzzle which is asked in the interview. Approach: Example: a = 3, b = 5 a = a + b...

Objective: Given a range of integers, find all the numbers which are palindrome when they are represented in Decimal Value( base 10) and in Octal value(base 8). Example : Number : 373 (Decimal) and...

Objective: Given a number, find out whether its colorful or not. Colorful Number: When in a given number, product of every digit of a sub-sequence are different. That number is called Colorful Number. See...

Objective: Given a set of numbers, print all the posssible subsets of it including empty set. Power Set: In mathematics, PowerSet of any given set S, PS(S) is set of all subsets of S...

Objective: Given a decimal number, convert it into irreducible fraction. Irreducible Fraction : An irreducible fraction is a fraction in which the numerator and denominator are integers that have no other common divisors than...

%d bloggers like this: