Skip to content

Category Archives: Java Programs

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
Transpose of a matrix is obtained by changing rows to columns and columns to rows. In other words, transpose of A[][] is obtained by changing… Read More
Factorial of a non-negative integer, is multiplication of all integers smaller than or equal to n. For example factorial of 6 is 6*5*4*3*2*1 which is… Read More
Tower of Hanoi is a mathematical puzzle where we have three rods and n disks. The objective of the puzzle is to move the entire… Read More
Given an array, find the largest element in it. Input : arr[] = {10, 20, 4} Output : 20 Input : arr[] = {20, 10,… Read More
Given an integer n, write a function that returns count of trailing zeroes in n!.  Examples : Input: n = 5 Output: 1 Factorial of… Read More
Catalan numbers are a sequence of natural numbers that occurs in many interesting counting problems like following. 1) Count the number of expressions containing n… Read More
Bubble Sort is the simplest sorting algorithm that works by repeatedly swapping the adjacent elements if they are in wrong order. Java   Java //… Read More
The selection sort algorithm sorts an array by repeatedly finding the minimum element (considering ascending order) from unsorted part and putting it at the beginning.… Read More
Given an array of integers. Write a Java Program to find the sum of the elements of the array. Examples: Input : arr[] = {1,… Read More
So as we all know binary search is one of the searching algorithms that is most frequently applied while dealing with data structures where the… Read More
Like Merge Sort, QuickSort is a Divide and Conquer algorithm. It picks an element as pivot and partitions the given array around the picked pivot.… Read More
Given a number ‘n’, how to check if n is a Fibonacci number. First few Fibonacci numbers are 0, 1, 1, 2, 3, 5, 8,… Read More

Start Your Coding Journey Now!