Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bubblesort over other sorting algorithms?

Why would you choose bubble sort over other sorting algorithms?

like image 936
Neel Avatar asked Mar 20 '11 19:03

Neel


People also ask

What are the advantage of bubble sort over other sorting algorithms?

Explanation: Optimised Bubble sort is one of the simplest sorting techniques and perhaps the only advantage it has over other techniques is that it can detect whether the input is already sorted. It is faster than other in case of sorted array and consumes less time to describe whether the input array is sorted or not.

Which algorithm is better for sorting between Bubblesort and merge?

Merge Sort is considered to be one of the fastest sorting algorithms, it is a bit more complex than Selection and Bubble Sort but its more efficient. The idea of Merge Sort is to divide the data-set into smaller data-sets, sort those smaller data-sets and then join them (merge them) together.

What is difference between Bubblesort and merge sort?

Merge Sort - Is a 'Divide and Conquer' algorithm that splits a list into discrete elements and then merges the elements back together in order. A merge sort is quicker and more efficient than a bubble sort when using longer lists. However, it uses more memory and can take longer to sort shorter lists.

Which sorting algorithm is best?

Quicksort. Quicksort is one of the most efficient sorting algorithms, and this makes of it one of the most used as well. The first thing to do is to select a pivot number, this number will separate the data, on its left are the numbers smaller than it and the greater numbers on the right.


1 Answers

There's one circumstance in which bubble sort is optimal, but it's one that can only really occur with ancient hardware (basically, something like a drum memory with two heads, where you can only read through the data in order, and only work with two data items that are directly next to each other on the drum).

Other than that, it's utterly useless, IMO. Even the excuse of getting something up and running quickly is nonsense, at least in my opinion. A selection sort or insertion sort is easier to write and/or understand.

like image 62
Jerry Coffin Avatar answered Sep 30 '22 02:09

Jerry Coffin