/algos

A collection of common algorithms implemented in a variety of languages

Primary LanguageC++OtherNOASSERTION

Algos

A collection of common algorithms implemented in a variety of languages.

Algorithms

Searching

Name Worst Average Best Space
Linear Search $O(n)$ $O(n)$ $O(1)$ $O(1)$
Binary Search $O(\log_{2}{n})$ $O(\log_{2}{n})$ $O(1)$ $O(1)$
Ternary Search $O(\log_{3}{n})$ $O(\log_{3}{n})$ $O(1)$ $O(1)$
K-ary Search $O(log_{k+1}{n})$ $O(\log_{k+1}{n})$ $O(1)$ $O(1)$

Sorting

Name Method Worst Average Best Space
Insertion Sort Inserting $O(n^2)$ $O(n^2)$ $O(n)$ $O(1)$
Selection Sort Selecting $O(n^2)$ $O(n^2)$ $O(n^2)$ $O(1)$
Merge Sort Merging $O(n\log_{2}{n})$ $O(n\log_{2}{n})$ $O(n\log_{2}{n})$ $O(n)$
Quick Sort Partitioning $O(n^2)$ $O(n\log_{2}{n})$ $O(n\log_{2}{n})$ $O(\log_{2}{n})$
Bubble Sort Exchanging $O(n^2)$ $O(n^2)$ $O(n)$ $O(1)$

Languages