Expected/Worst-case Big O Complexity & Data Structures
Logarithmic Time O(log(n))
Worst-case time searching in: B-Tree
Linear Time O(n)
Worst-case time searching in: Binary Search Tree
Linear Time O(n)
Worst-case time searching in: Doubly-Linked List
Linear Time O(n)
Worst-case time searching in: Hash Table
Linear Time O(n)
Worst-case time searching in: Singly-Linked List
Linear Time O(n)
Worst-case time searching in: Stack
Logarithmic Time O(log(n))
Worst-case time inserting element in: B-Tree
Linear Time O(n)
Worst-case time inserting element in: Binary Search Tree
Constant Time O(1)
Worst-case time inserting element in: Doubly-Linked List
Linear Time O(n)
Worst-case time inserting element in: Hash Table
Linear Time O(n)
Worst-case time searching in: Queue
Logarithmic Time O(log(n))
Worst-case time searching in: Red-Black Tree
Bubble Sort (Sinking Sort)
Also called sinking sort, it is a simple sorting algorithm that repeatedly steps through the list to be sorted, compares each pair of adjacent items and swaps them if they are in the wrong order. The pass through the list is repeated until no swaps are needed, which indicates the list is sorted.
Queue
An abstract data type that resembles a sequential collection. Contains two principal operations: enqueue for insertion, and dequeue for removal. The order of which the elements are stored/removed is first-in-first-out (FIFO)/last-in-last-out(LILO), respectively.
Stack
An abstract data type that serves as a collection of elements with three principal operations: push, pop, and peek. The order of which the elements are stored/removed is first-in-last-out (FILO)/last-in-first-out (LIFO), respectively.
Linear Time O(n)
Expected time accessing element in: Singly-Linked List
Linear Time O(n)
Expected time accessing element in: Stack
Linear Time O(n)
Expected time deleting element in: Array
Logarithmic Time O(log(n))
Expected time deleting element in: B-Tree
Logarithmic Time O(log(n))
Expected time deleting element in: Binary Search Tree
Constant Time O(1)
Expected time deleting element in: Doubly-Linked List
Constant (Amortized) Time O(1)
Expected time deleting element in: Hash Table
Constant Time O(1)
Expected time deleting element in: Queue
Logarithmic Time O(log(n))
Expected time deleting element in: Red-Black Tree
Constant Time O(1)
Expected time deleting element in: Singly-Linked List
Constant Time O(1)
Expected time deleting element in: Stack
Linear Time O(n)
Expected time inserting element in: Array
Logarithmic Time O(log(n))
Expected time inserting element in: B-Tree
Logarithmic Time O(log(n))
Expected time inserting element in: Binary Search Tree
Constant Time O(1)
Expected time inserting element in: Doubly-Linked List
Constant (Amortized) Time O(1)
Expected time inserting element in: Hash Table
Constant Time O(1)
Expected time inserting element in: Queue
Logarithmic Time O(log(n))
Expected time inserting element in: Red-Black Tree
Constant Time O(1)
Expected time inserting element in: Singly-Linked List
Constant Time O(1)
Expected time inserting element in: Stack
Linear Time O(n)
Expected time searching in: Array
Logarithmic Time O(log(n))
Expected time searching in: B-Tree
Logarithmic Time O(log(n))
Expected time searching in: Binary Search Tree
Linear Time O(n)
Expected time searching in: Doubly-Linked List
Constant Time O(1)
Expected time searching in: Hash Table
Linear Time O(n)
Expected time searching in: Queue
Logarithmic Time O(log(n))
Expected time searching in: Red-Black Tree
Linear Time O(n)
Expected time searching in: Singly-Linked List
Linear Time O(n)
Expected time searching in: Stack
Array
A data structure consisting of a collection of elements, each identified by an index. A high-level, list-like object.
Hash Table
A data structure used to implement an associative array, a structure that can map keys to values. Uses a hash function to compute an index into an array of buckets, from which the desired value can be found.
Quicksort
A divide and conquer algorithm, first by dividing a large array into two smaller sub-arrays: the low elements and the high elements. Next, an element is chosen as the pivot, where elements with a value lower than itself are recursively ordered to before the pivot, and values greater are reordered to after (called partitioning).
Mergesort
A divide and conquer algorithm, first by dividing the unsorted list into 'n' sublists, each containing at least 1 element (a list of 1 element is already considered sorted). Next, repeatedly merge sublists to produce new sorted sublists until there is only one sublist remaining. This will be the sorted list.
Tree
A hierarchal data structure with a root value and subtrees of children
Red-Black Tree
A kind of self-balancing BST. Each node of the binary tree has an extra bit, and that bit is often interpreted as a color. These color bits are used to ensure the tree remains approximately balanced during insertions and deletions.
B-Tree
A self-balancing data structure that keeps data sorted and allows searches, sequential access, insertions, and deletions in logarithmic time. An organizational structure for information storage and retrieval in which all terminal nodes are the same distance from the base, and all nonterminal nodes have between n and 2n subtrees or pointers (where n is an integer)
Insertion Sort
A simple sorting algorithm that builds the final sorted array (or list) one item at a time. Each iteration, it removes one element from the input data, finds the location it belongs within the sorted list, and puts it there. Repeats until no input elements remain. Much less efficient on large lists than more advanced algorithms, but is more efficient, adaptive, stable, in-place, and online than some other algorithms.
Logarithmic Time O(log(n))
Expected time accessing element in: Red-Black Tree
Selection Sort
An in-place comparison sort with a quadratic (O(n^2)) time complexity. Divides the input list into two parts: the sublist of items already sorted, which is built from left to right at the front of the list, and the sublist of items remaining to be sorted that occupy the rest of the list. Finds the smallest (or largest, depending on the sorting order) element in the unsorted sublist, exchanging (swapping) it with the leftmost unsorted element (putting it in sorted order, and moving the sublist boundaries one element to the right.
Constant Time O(1)
Expected time accessing element in: Array
Logarithmic Time O(log(n))
Expected time accessing element in: B-Tree
Logarithmic Time O(log(n))
Expected time accessing element in: Binary Search Tree
Doubly Linked List
Data structure that consists of sequentially linked records called nodes. Each node contains two fields that are references to the previous and to the next node in the sequence of nodes.
Linear Time O(n)
Expected time accessing element in: Doubly-Linked List
Linear Time O(n)
Expected time accessing element in: Queue
Linked List
Linear collection of nodes, each containing data (a value) and a pointer to the next node that follows it. Constructors typically contain a head and tail node.
Binary Search Tree
Similar to a doubly linked list in that each node contains some data as well as two pointers to other nodes; they differ in the way that those nodes relate to one another. This node's pointers are typically called "left" and "right" to indicate subtrees of values relating to the current value.
Big O Notation
The relative representation of the complexity of an algorithm. Used to determine the best, expected (or average), and worst case of an algorithm.
Constant Time O(1)
Worst-case time inserting element in: Queue
Logarithmic Time O(log(n))
Worst-case time inserting element in: Red-Black Tree
Constant Time O(1)
Worst-case time inserting element in: Singly-Linked List
Constant Time O(1)
Worst-case time inserting element in: Stack
Linear Time O(n)
Worst-case time searching in: Array
Constant Time O(1)
Worst-case time accessing element in: Array
Logarithmic Time O(log(n))
Worst-case time accessing element in: B-Tree
Linear Time O(n)
Worst-case time accessing element in: Binary Search Tree
Linear Time O(n)
Worst-case time accessing element in: Doubly-Linked List
Linear Time O(n)
Worst-case time accessing element in: Queue
Logarithmic Time O(log(n))
Worst-case time accessing element in: Red-Black Tree
Linear Time O(n)
Worst-case time accessing element in: Singly-Linked List
Linear Time O(n)
Worst-case time accessing element in: Stack
Linear time O(n)
Worst-case time deleting element in: Array
Logarithmic Time O(log(n))
Worst-case time deleting element in: B-Tree
Linear Time O(n)
Worst-case time deleting element in: Binary Search Tree
Constant Time O(1)
Worst-case time deleting element in: Doubly-Linked List
Linear Time O(n)
Worst-case time deleting element in: Hash Table
Constant Time O(1)
Worst-case time deleting element in: Queue
Logarithmic Time O(log(n))
Worst-case time deleting element in: Red-Black Tree
Constant Time O(1)
Worst-case time deleting element in: Singly-Linked List
Constant Time O(1)
Worst-case time deleting element in: Stack
Linear Time O(n)
Worst-case time inserting element in: Array