# Category: MISC

## 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...

## Minimum number of guesses needed to find a specific 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....

## Find the Area of a Triangle Using coordinates

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,...

## Java Program to find if Triangle can be formed using given 3 sides

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...

## Find the Area of a Triangle Given Three Sides – Heron’s Formula

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,...

## Find Factorial of a given Number

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...

## Find Sum of all Digits of a Number

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...

## Check whether the given number is a perfect square

Objec­tive:  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...

## Algorithm to calculate power(k,n).

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 =...

## Find remainder without using modulo operator

Objec­tive:  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 =...

## Swap two numbers without using extra variable

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...

## Find numbers which are palindrome in both their decimal and octal Representations

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...

## Colorful Numbers

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...

## Print All the Subsets of a Given Set (Power Set)

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...

## Convert Decimal into Irreducible Fraction

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...