Recursion Concept with Example

What is recursion and how to use recursion in programming. If you are new to programming, then recursion concept is tough to understand. In this post, i’ll explain the concept of recursion with example.

What is Recursion ?

In Recursion, function call itself repeatedly, until the base or terminating condition is not true. To understand this statement let’s take an example.

Suppose, we have to print a number between start to end range. Let’s print number between 1 to 10.

It’s a much preferred way to write cleaner and shorter code for many complex problems.

Through recursion, you can reduce complex problem into smaller version.

Find Duplicate Elements in an Array – Java Program

Write a java program to find duplicate elements in an array. Given an array of integers, We have to write a code to find all duplicate elements in an array.

For example :

Input : arr = { 2, 5, 3, 1, 8, 7, 5, 3, 2 }

Output: {5, 3, 2}

In this tutorial, I am going to explain three approaches to find duplicate elements in an array. This question is also very important for technical interviews.

C Program to Swap two Numbers without using third variable

Write a c program to swap two numbers without using third variable. Given two input numbers, We have to write a code to swap two numbers without using third variable. In my previous post, I have explained a c program to swap two numbers using third variable. This question is generally asked in an interview.

Programming questions on linked list

Swap two numbers using Bitwise XOR Operator