AdBlock Detected!

Our website is made possible by displaying ads to our visitors. Please support us by whitelisting our website.

Computer Neek

Sorting Algorithms

Bubble sort

A bubble sort is a type of sorting algorithm that sorts an unordered list.

How does it work

A bubble sort works by swapping adjacent items until it's in order. It's the most inefficient of the sorting algorithms but it's easy to implement. As a result it is often used for small data sets. The time complexity of a bubble sort is O(n^2).

Merge Sort

A merge sort is a type of sorting algorithm that sorts an unordered list using a divide and conquer method.

How does it work

A merge sort halves the lists up until they are in pair.

A picture of a merge sort

Searching algorithms

Linear Search

A linear search is a type of searching algorithm that sequentially checks each element of the list until a match is found. It has a time complexity of O(n).

Binary Search

A binary search is a type of searching algorithm that finds an item in a sorted list by a method of divide and conquer.

How does it work.

In a binary search, the midpoint of the item is found and from there, it checks if the desired value is greater than or less than that value. In the binary search example below, the number 4 is the value we are looking for and the red items are the values that are not needed. A binary search has a time complexity of O(Log n).

A picture of binary Search