Bubble sort explained with simple example

Bubble sort is one of the simplest sorting algorithm which traverse through the list, compares items at adjacent places, and swaps them to make list sorted. After every pass of list one or more item is placed at its correct position. If in a pass, no swaps are performed then it means list becomes sorted.

Pros:
1) Simple algorithm.
2) No extra memory needed.
3) Good for cases when list is almost sorted (only few misplaced items).

Cons:
1) Very slow algorithm. Not good for very large set of data.

(more…)

Bubble sort explained with simple example Read More

Sorting algorithms explained in simple manner

Sorting is an operation in computer science via which data is being arranged in an ordered sequence. There are lots of efficient algorithms are already present to perform sorting operation which we are going to discuss here.

Some of the most used sorting algorithms are as follows:

1) Bubble Sort
2) Insertion Sort
3) Merge Sort
4) Selection Sort
5) Quick Sort
6) Heap Sort

Comparison of various Sorting algorithms in terms of time complexity for best and worst case:

(more…)

Sorting algorithms explained in simple manner Read More