Binary Search using Recursion in Java

In this tutorial, I am going to discuss the implementation of a Binary search using recursion in java.

Given an array of sorted integers and a number k. We have to write a code to search  an element k in an array.

For example:

Input: {2, 3, 4, 5, 7, 8},     k = 5

Output: 3 (5 is found at 3rd index)

Input array is sorted and we have to find 5 in this array. The element is found at index 3.

Find GCD of Two Numbers using Recursion – Java Code

How to find GCD of two numbers. In this tutorial, I am going to discuss multiple approaches to find GCD of two numbers using Recursion.

Given two input integers, we have to write a code to find GCD of two numbers using recursion.

For example:

Input  n1 : 36    n2 : 54

Output 18

Explanation :

The divisiors of 36 are 1, 2, 3, 4, 6, 9, 12, 18, 36  and the divisiors of 54 are 1,  2,  3,  6,  9,  18,  27,  54.

Common divisors are 1, 2, 3, 6, 9, 12 and 18.

The GCD (Greatest Common Divisior) for 36 and 54 is 18.

For this program, I assume you are familiar with the concept of recursion. If you don’t know about recursion then check my previous post on recursion vs iteration.

Multiply Two Numbers without using * (Multiplication Operator)

Write a C program to multiply two numbers without using * multiplication operator.

Given two numbers, both numbers are positive.  Write a program to multiply two numbers without using * multiplication operator.  This problem is bit tricky as we are not allowed to use multiplication operator .

We can use multiple approaches to solve this problem. In this tutorial, i am going to explain how to multiply two numbers using recursion as well as using iterative approach.

C Program to Multiply Two Numbers without using *

C Program to Multiply Two Numbers without using *