Sorting Algorithms

A sorting algorithm will put items in a list into a particular order, which may be alphabetic or numeric. As sorting a large list of items can be timely, computer algorithms have been developed to do the work for us. There are two types of sorts you need to know, but many others.

 

Merge Sort

The merge sort is a sorting technique based on the idea of  ‘divide and conquer’.

 

A merge sort divides a list into half, again and again until each data item is separate.

 

Then the items are combined in the same way as they were divided, but now in the correct order.

 

Bubble Sort

This algorithm is based on the comparison of adjacent data elements.

Data elements are swapped if they are not in the correct order.

 

A bubble sort is not suitable for large sets of data.

Questo's Corner

Sorting Algorithms:

a. Describe step-by-step how the numbers '32, 16, 04, 08, 22, 11' can be sorted using merge sort.

b. Describe step-by-step how the numbers '32, 16, 04, 08, 22, 11' can be sorted using bubble sort.

© CSNewbs 2020