# Sorting Algorithms

**6**Pins

**2**Followers

Given an array, sort the array using Insertion Sort algorithm. Insertion sort is a simple sorting algorithm in which sorting is done by picking one array element at a time and inserting it into already sorted subarray. Insertion sort is an in-place comparison sort. Insertion sort is a stable sorting algorithm i.e. after sorting, the order of elements with same value is not changed. Insertion sort is an online sorting algorithm i.e. it can sort a list as and when it receives it. Java…

#### Sorting Algorithm - Insertion Sort

Given an array, sort the array using Bubble Sort algorithm. Bubble sort is an in-place comparison sort. Bubble sort algorithm compares each pair of adjacent elements and swaps them if they are in the wrong order. The pass through the array is repeated until no swaps are needed, which indicates that the array is sorted. Java code is given in the code snippet section. Java visualization is provided in algorithm visualization section.

#### Sorting Algorithm - Bubble Sort

Given an array, sort the array using Selection Sort algorithm. The algorithm divides the input array into two parts: the subarray of items already sorted, which is built up from left to right, and the subarray of items remaining to be sorted that occupy the rest of the array. Initially, the sorted subarray is empty and the unsorted subarray is the entire input array. The algorithm proceeds by finding the smallest element in the unsorted subarray, swapping it with the leftmost unsorted…