Algorithm

Heap Sort in Java

Posted on Updated on

Heap Sort is a comparison-based sorting algorithm to create a sorted array. It is similar to selection sort where we first find the maximum element from array and place it at the end. We repeat this process for each element in the given array. Heap Sort is based on Binary Heap data structure. In this program we will be sorting the given array in ascending order. Read the rest of this entry »

Implement Max Heap in Java

Posted on Updated on

Max Heap:

Here in this blog we should see implementation of Max Heap.

The value of each node is less than or equal to value of its parent. Thus, root contains max value. Read the rest of this entry »

Implement Min Heap in Java

Posted on Updated on

Min Heap:

Here in this blog we should see implementation of Min Heap.

The value of each node is greater than or equal to value of its parent. Thus, root contains min value. Read the rest of this entry »

Binary Heap

Posted on Updated on

Heap data structure is widely use in software languages like C, C++, Python, Java etc. There are different type of heaps like Binary Heap, Fibonacci Heap, Binomial Heap and so on. Out of these, Binary Heap is more popular and others are variations of it. Following are the properties of Binary Heap.

  1. Binary tree property: It’s a complete tree i.e All levels are completely filled except last levels which has all keys as left as possible.
  2. Binary Heap is either a Max heap or Min Heap.

Read the rest of this entry »