Java Sorting

Heap Sort

Heap Sort in Java Heap sort is a comparison-based sorting technique which is based on Binary Heap Data Structure. Heap Sort is an optimization of selection sort where we first find the max (or min) element swapping it with the last (or first). and we repeat the same process for the remaining elements. In Heap […]

Heap Sort Read More »

Merge Sort

Merge Sort in Java The merge sort is a divide and conquer algorithm that divides the input array into equal subarrays and then merges back those subarrays into a sorted array. The process of merge sort is to divide the array into two equal subarrays, sort each subarray, and then merge the sorted subarrays back

Merge Sort Read More »

Quick Sort

Quick Sort in Java Quicksort algorithm is based on the divide and conquer approach where an array is divided into subarrays by selecting a pivot element.The pivot element is positioned in such a way that elements less than pivot are kept on the left side and elements greater than pivot are on the right side.The

Quick Sort Read More »

Selection Sort

Selection Sort in Java Selection Sort is a comparison-based sorting algorithm that sorts an array by repeatedly finding the minimum element (considering ascending order) from the unsorted part and putting it at the beginning. The process is continued until the entire array is sorted. Algorithm for Selection Sort Step 1 : Set the first element as

Selection Sort Read More »

Insertion Sort

Insertion Sort in JavaInsertion sort is a sorting algorithm that places an unsorted element in a sorted list in each iteration.Insertion sort works similar to sorting cards in our hand in a card game in which we place the first card which is already sorted then, we select an unsorted card. If the unsorted card

Insertion Sort Read More »

Bubble Sort

Bubble Sort in Java Bubble sort is a sorting algorithm that compares two adjacent elements and swaps them if they are in the wrong order that’s expected. Bubble sort algorithm is not suitable for large data sets as its average and worst-case time complexity are quite high. Algorithm for Bubble Sort in Java 1) Start

Bubble Sort Read More »

Scroll to Top