Old Magnifying Glass
A binary search is a way to find an item in a sorted list by repeatedly dividing the list in half and comparing the middle value with the target value until the target is found or the list is exhausted. It is faster than a linear search for large lists.
Linear search is a way to find an item in an unsorted or sorted list by checking each element in sequence until the target value is found or the end of the list is reached. It is simple but slower than a binary search for large lists
Bubble sort – moving through a list repeatedly swapping elements that are in the wrong order.
Simple and easy to understand.
Very slow for large datasets.
Bubble sort
Take the first element and second element from the list
Compare them
IF element 1 > element 2 THEN
Swap them
ELSE
Do nothing
Repeat: Move along the list to the next pair
IF no more elements: Go to 1
ELSE: Go to next
Until: you have moved through the entire list and not made any changes
Insertion sort – each items is take in turn, compare to the items in a sorted list and placed in the correct position.
Ordered List – Elements are arranged in sequence
Unordered List – Unarranged elements
Efficient for small datasets
Outperforms other sorting algorithms for very small datasets
Merge sort – a list is split into individual lists, these are then combined
List – a set of data
Divides the input data into smaller pieces, making it more efficient for large datasets.
Uses additional memory for merging and sorting.
Merging lists
Compare the first element in both lists.
Put the smallest into a new list.
Compare the next element of 1 list with the second element of the 2nd list.
Put the smallest into a new list.
Repeat until merged.
Art style for this page - Oil Painting