Explore tens of thousands of sets crafted by our community.
Data Structures Overview
25
Flashcards
0/25
Stack
A LIFO (last in, first out) data structure. Complexity: Access - O(n), Search - O(n), Insertion - O(1), Deletion - O(1)
Linked List
A linear collection of data elements, whose order is not given by their physical placement in memory. Complexity: Access - O(n), Search - O(n), Insertion - O(1), Deletion - O(1)
Binary Search Tree (BST)
A binary tree where each node follows the left child is lesser and the right child is greater rule. Complexity: Access - O(log n), Search - O(log n), Insertion - O(log n), Deletion - O(log n)
AVL Tree
A self-balancing Binary Search Tree where the difference between heights of left and right subtrees cannot be more than one for all nodes. Complexity: Access - O(log n), Search - O(log n), Insertion - O(log n), Deletion - O(log n)
Binary Tree
A tree data structure in which each node has at most two children. Complexity: Access - O(n), Search - O(n), Insertion - O(log n), Deletion - O(log n)
Heap
A specialized tree-based data structure which is essentially an almost complete tree that satisfies the heap property. Complexity: Access (Max/Min) - O(1), Search - O(n), Insertion - O(log n), Deletion - O(log n)
Hash Table
A data structure which implements an associative array, a structure that can map keys to values. Complexity: Access - N/A, Search (average case) - O(1), Insertion (average case) - O(1), Deletion (average case) - O(1)
Array
A collection of items stored at contiguous memory locations. Complexity: Access - O(1), Search - O(n), Insertion - O(n), Deletion - O(n)
Queue
A FIFO (first in, first out) data structure. Complexity: Access - O(n), Search - O(n), Insertion - O(1), Deletion - O(1)
Tree
A hierarchical data structure with a root value and subtrees of children with a parent node. Complexity: Access - O(n), Search - O(n), Insertion - O(log n), Deletion - O(log n)
Segment Tree
A tree data structure for storing intervals or segments. It allows querying which of the stored segments contain a given point. Complexity: Access - N/A, Search - O(log n), Update - O(log n), Range Query - O(log n)
Sparse Table
A data structure that allows answering range queries. It can answer range min/max queries in O(1) time with O(n log n) preprocessing time. Complexity: Preprocessing - O(n log n), Range Query - O(1)
Disjoint Set (Union-Find)
A data structure that keeps track of a set of elements partitioned into a number of disjoint (non-overlapping) subsets. Complexity: Union - O(log n), Find - O(log n), but with path compression and union by rank or size, these operations can work nearly in O(1)
Graph
A collection of nodes or vertices connected by edges. Complexity for Adjacency List: Access - O(1), Search - O(V+E), Insertion - O(1), Deletion - O(1). Complexity for Adjacency Matrix: Access - O(1), Search - O(V^2), Insertion - O(1), Deletion - O(1). Here V is the number of vertices and E is the number of edges.
Deque
A double-ended queue that allows insertions and deletions from both ends. Complexity: Access - O(n), Search - O(n), Insertion - O(1), Deletion - O(1)
Priority Queue
An abstract data type where each element has a priority and the element with the highest priority is served before other elements. Complexity: Access (Max/Min) - O(1), Search - O(n), Insertion - O(log n), Deletion (Max/Min) - O(log n)
Cartesian Tree
A binary tree derived from a sequence of numbers; it can be used to create a static range minimum query structure. Complexity: Access - N/A, Search - N/A, Insertion - O(n), Deletion - N/A
K-d Tree
A space-partitioning data structure for organizing points in a k-dimensional space. K-d trees are useful for applications such as searches involving a multidimensional search key. Complexity: Construction - O(n log n), Search - O(log n), Insertion - O(log n), Deletion - O(log n)
Double Linked List
Similar to Linked List, but each node contains an additional pointer to the previous node. Complexity: Access - O(n), Search - O(n), Insertion - O(1), Deletion - O(1)
Red-Black Tree
A self-balancing binary search tree where each node contains an extra bit for denoting the color of the node, red or black. Complexity: Access - O(log n), Search - O(log n), Insertion - O(log n), Deletion - O(log n)
Suffix Tree
A compressed trie containing all the suffixes of the given text as their keys and positions in the text as their values. Complexity: Access - Not applicable, Search - O(length of search string), Insertion - O(n), Deletion - Not generally supported
B-Tree
A self-balancing tree data structure that maintains sorted data and allows searches, sequential access, insertions, and deletions in logarithmic time. Complexity: Access - O(log n), Search - O(log n), Insertion - O(log n), Deletion - O(log n)
Suffix Array
A sorted array of all suffixes of a string. Complexity: Building - O(n log n), Search - O(m log n) where m is the size of the pattern to be searched
Fenwick Tree (Binary Indexed Tree)
A data structure that provides efficient methods for calculation and manipulation of the prefix sums of a table of values. Complexity: Access - O(log n), Search - N/A, Update - O(log n), Range Sum Query - O(log n)
Trie
A tree-like data structure used to store a dynamic set or associative array where the keys are usually strings. Complexity: Access - O(length of key), Search - O(length of key), Insertion - O(length of key), Deletion - O(length of key)
© Hypatia.Tech. 2024 All rights reserved.