## Binary Search

public class BinarySearch { static int search(int arr[], int el) { int l = 0; int h = arr.length - 1; while(l <= h){ int mid = (l + h)…

## Linear Search

public class LinearSearch { static int search(int arr[], int el) { for (int i = 0; i < arr.length; i++) { if (arr[i] == el) { return i + 1;…

## Recursion

When a function calls itself it is known as recursion. Program to find factorial of no using recursion public class FactorialUsingRecursion { public static void main(String[] args) { System.out.println(fact(5)); }…

## Trees

A tree is a non-linear Data structure where is data is stored in the form of tree node. Types of trees Binary Tree A binary tree a node can have…

## Time Complexities Table

Here is a list of some of the common time complexities. Time ComplexitiesNameExampleO(1)Constant- Accessing an element of an array- Adding element at beginning of a linked listO(log n)Logarithmic- Finding an…

## Implementing Queue using Arrays

public class Queue { private int front, rear, capacity; private int[] queue; Queue(int size) { this.front = 0; this.rear = 0; this.capacity = size; this.queue = new int[capacity]; } void…

## Arrays Questions

Array Questions Write a program to find maximum and minimum element in an integer array.Write a program to add all the elements of the array.Program to find whether the given…

## Differences between Recursion Vs Iteration

Recursion Terminates when a base case is reachedEach call requires extra space in stack frameFor infinte recursion, program may run out of memorySolutions are easily to formulate recursively Iteration Terminates…

## How to Compare Algorithms

We can compare algorithms based on the following method Execution Time We can compare algorithm based on the time it takes to execute some input. But the thing is the…

## Importance of Analysis of Algorithm

Algorithm analysis helps us determine the efficiency of the algorithm with respect to the time and space it uses. Let's understand it with an example Suppose you want to transfer…