# Algorithms

In mathematics and computer science, an algorithm is a finite sequence of
well-defined, computer-implementable instructions, typically to

solve a class of specific problems or to perform a computation.

## Sort Algorithms

Bubble Sort Algorithm

A simple sorting algorithm that repeatedly steps through an array, compares adjacent elements, and swaps them if they are in the wrong order until the array is sorted.

Selection Sort Algorithm

A simple sorting algorithm that repeatedly selects the minimum element from the unsorted portion of an array and swaps it with the first element in the unsorted portion.

Insertion Sort Algorithm

A simple sorting algorithm that builds the final sorted array one element at a time by repeatedly shifting elements to the right and inserting the next element in the correct position.

Merge Sort Algorithm

A divide-and-conquer sorting algorithm that splits an array into smaller sub-arrays, sorts them, and then merges the sorted sub-arrays to form the final sorted array.

Quick Sort Algorithm

A divide-and-conquer sorting algorithm that selects a pivot element, partitions the array around the pivot, and recursively sorts the partitions.

Heap Sort Algorithm

A comparison-based sorting algorithm that uses a binary heap data structure to efficiently sort an array.

Counting Sort Algorithm

A non-comparison-based sorting algorithm that counts the number of occurrences of each element in an array and uses that information to sort the elements.

A non-comparison-based sorting algorithm that sorts elements based on the digits of their values in a specific radix or base.

Bucket Sort Algorithm

A non-comparison-based sorting algorithm that distributes elements into buckets based on their values and then sorts the elements within each bucket.

Bingo Sort Algorithm

A humorously named sorting algorithm that generates random numbers until they are in the correct order.

Shell Sort Algorithm

A variation of the insertion sort algorithm that improves its performance by exchanging elements that are far apart instead of just swapping adjacent elements.

TimSort Algorithm

A sorting algorithm used by the Python programming language and other systems, based on the merge sort and insertion sort algorithms

Comb Sort Algorithm

A variation of the bubble sort algorithm that uses a larger gap between elements to improve its performance.

Pigeonhole Sort Algorithm

A non-comparison-based sorting algorithm that sorts elements by putting them into pigeonholes based on their values.

Cycle Sort Algorithm

A sorting algorithm that minimizes the number of writes performed during the sorting process.

Cocktail Sort Algorithm

A variation of the bubble sort algorithm that sorts elements in both directions.

## Search Algorithms

Mastering Binary Search

My personal study notes for tackling binary search and its many variations.

Implementation for each variation in javascript, leetcode problems linked to so that you can practice, and a break down on how to identify whether you're tackling a binary search problem or not so that you know whether to pull upon one the binary search variations we dive into

Hash Table Search Algorithm

A search algorithm that uses a hash table data structure to map keys to values and provides an average O(1) time complexity for searching.

Linear Search Algorithm

A simple search algorithm that iterates through a list or array, one element at a time, to find a target value. The time complexity is O(n) in the worst case.

Sentinel Linear Search Algorithm

A variation of linear search that improves its time complexity by checking the last element of the array first, reducing the number of comparisons.

Binary Search Algorithm

A divide-and-conquer search algorithm that repeatedly splits the list or array in half to find the target value. It has a time complexity of O(log n) in the worst case.

Meta Binary/One-sided Search

A variation of binary search that performs the search in one direction (left or right) rather than in both directions.

Ternary Search Algorithm

A search algorithm that splits the array into three parts and performs the search in the subarray with the highest probability of finding the target value. It has a time complexity of O(log3 n).

Jump Search Algorithm

A search algorithm that uses jumps of a fixed length to quickly move through a list or array, reducing the number of comparisons. The time complexity is O(√n).

Interpolation Search Algorithm

A search algorithm that uses the value of the desired item to estimate its position in the array and reduce the search space.

Exponential Search Algorithm

A search algorithm that starts by searching the first two elements, then repeatedly doubling the search interval until the target element is found or can't be found.

Fibonacci Search Algorithm

A search algorithm that uses the Fibonacci sequence to reduce the search interval.

The Ubiquitous Binary Search Algorithm

A reference to the widespread use and popularity of the binary search algorithm as a standard search algorithm in computer science and software engineering.

### What is an example of an algorithm?

One of the most obvious examples of an algorithm is a recipe. It's a finite list of instructions used to perform a task. For example, if you were to follow the algorithm to create brownies from a box mix, you would follow the three to five step process written on the back of the box.

What are the characteristics of algorithm?

Algorithm and its characteristics

What are the 5 properties of algorithm?

An algorithm must have five properties:

What are the types of algorithms?

Algorithm types we will consider include:

### What is Big O function?

Big O notation is a mathematical notation that describes the limiting behavior of a function when the argument tends towards a particular value or infinity. ... In computer science, big O notation is used to classify algorithms according to how their run time or space requirements grow as the input size grows.