Skip to content

Category Archives: Java Programs

Bitonic Sequence A sequence is called Bitonic if it is first increasing, then decreasing. In other words, an array arr[0..n-i] is Bitonic if there exists… Read More
Given a number “n”, find its total number of divisors is even or odd. Examples: Input: n = 10 Output: Even Input: n = 100… Read More
Pigeonhole sorting is a sorting algorithm that is suitable for sorting lists of elements where the number of elements and the number of possible key… Read More
Comb Sort is mainly an improvement over Bubble Sort. Bubble sort always compares adjacent values. So all inversions are removed one by one. Comb Sort… Read More
Given a number, find a representation of number as sum of non-consecutive Fibonacci numbers. Examples: Input: n = 10 Output: 8 2 8 and 2… Read More
GCD of two numbers is the largest number that divides both of them. A simple way to find GCD is to factorize both numbers and… Read More
GCD of two numbers is the largest number that divides both of them. A simple way to find GCD is to factorize both numbers and… Read More
Following is a typical recursive implementation of Merge Sort that uses last element as pivot. Java // Recursive Java Program for merge sort   import… Read More
Given two sorted arrays and a number x, find the pair whose sum is closest to x and the pair has an element from each… Read More
There are n stairs, a person standing at the bottom wants to reach the top. The person can climb either 1 stair or 2 stairs… Read More
We can use binary search to reduce the number of comparisons in normal insertion sort. Binary Insertion Sort find use binary search to find the… Read More
Given a text txt[0..n-1] and a pattern pat[0..m-1], write a function search(char pat[], char txt[]) that prints all occurrences of pat[] and its permutations (or… Read More
Given a positive integer N, count all possible distinct binary strings of length N such that there are no consecutive 1’s. Examples: Input: N =… Read More
In shellSort, we make the array h-sorted for a large value of h. We keep reducing the value of h until it becomes 1. An… Read More
Area of a circle can simply be evaluated using following formula. Area = pi * r2 where r is radius of circle Java // Java… Read More

Start Your Coding Journey Now!