# Category Archives: Java Programs

## Java Program for QuickSort

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 »

## Java Program for How to check if a given number is Fibonacci number?

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 »

## Java Program for Radix Sort

The Radix Sort Algorithm 1) Do following for each digit i where i varies from least significant digit to the most significant digit. ………….a) Sort… Read More »

## Java Program for Topological Sorting

Topological sorting for Directed Acyclic Graph (DAG) is a linear ordering of vertices such that for every directed edge uv, vertex u comes before v… Read More »

## Java Program for Counting Sort

Counting sort is a sorting technique based on keys between a specific range. It works by counting the number of objects having distinct key values… Read More »

## Java Program for Heap Sort

Heap sort is a comparison based sorting technique based on Binary Heap data structure. It is similar to selection sort where we first find the… Read More »

## Java Program for Merge Sort

Merge Sort is a Divide and Conquer algorithm. It divides input array in two halves, calls itself for the two halves and then merges the… Read More »

## Java Program for Insertion Sort

Insertion sort is a simple sorting algorithm that works the way we sort playing cards in our hands. Java filter_none edit close play_arrow link brightness_4… Read More »

## Java Program for Pancake sorting

Given an unsorted array, sort the given array. You are allowed to do only following operation on array. flip(arr, i): Reverse array from 0 to… Read More »

## Java Program for Maximum sum rectangle in a 2D matrix | DP-27

Given a 2D array, find the maximum sum subarray in it. For example, in the following 2D array, the maximum sum subarray is highlighted with… Read More »

## Java Program for efficiently print all prime factors of a given number

Given a number n, write an efficient function to print all prime factors of n. For example, if the input number is 12, then output… Read More »

## Java Program for Subset Sum Problem | DP-25

Given a set of non-negative integers, and a value sum, determine if there is a subset of the given set with sum equal to given… Read More »

## Java Program for Dijkstra’s shortest path algorithm | Greedy Algo-7

Given a graph and a source vertex in the graph, find shortest paths from source to all vertices in the given graph. Dijkstra’s algorithm is… Read More »

## Java Program for Iterative Quick Sort

filter_none edit close play_arrow link brightness_4 code // Java implementation of iterative quick sort class IterativeQuickSort {     void swap(int arr[], int i, int j)     {… Read More »

## Java Program for Sieve of Eratosthenes

Given a number n, print all primes smaller than or equal to n. It is also given that n is a small number. For example,… Read More »