What is Bubble Sort and Quick sort?Bubble Sort: - The simplest sorting algorithm. It takes two array elements at a time, compares them and swaps their positions if element on left is greater than right. Divides the array elements in two halves or partitions. On dividing, the quick sort procedure is recursively called to sort the two halves. A “pivot” is used as the center point and elements less than the pivot are moved to the left or before the pivot and elements greater than pivot are moved to the right. What is Bubble Sort and Quick sort?Bubble Sort: The simplest sorting algorithm. It involves the sorting the list in a repetitive fashion. It compares two adjacent elements in the list, and swaps them if they are not in the designated order. It continues until there are no swaps needed. This is the signal for the list that is sorted. It is also called as comparison sort as it uses comparisons.
Quick Sort: The best sorting algorithm which implements the ‘divide and conquer’ concept. It first divides the list into two parts by picking an element a ’pivot’. It then arranges the elements those are smaller than pivot into one sub list and the elements those are greater than pivot into one sub list by keeping the pivot in its original place.
|