V

Algorithm Visualizer

ZHEN
Share on WeiboShare on XGitHub repositoryAuthor website
Learning ToolsAlgorithm Complexity ReferenceAlgorithm Learning Paths
Data StructuresArrayLinked ListStackQueue and DequeBinary Search TreeBinary HeapHash TableGraphTrieDisjoint Set UnionLRU CacheSkip ListSegment TreeB+ TreeBloom FilterFenwick Tree
SortingBubble SortCocktail Shaker SortBitonic SortSelection SortInsertion SortBinary Insertion SortShell SortMerge SortTop-Down Merge SortQuick SortThree-Way Quick SortDual-Pivot Quick SortHeap SortCounting SortRadix SortBucket Sort
Graph AlgorithmsDijkstra's Shortest PathKruskal's Minimum Spanning TreePrim's Minimum Spanning TreeBellman-Ford Shortest PathsTopological SortFloyd-WarshallStrongly Connected Components2-SATMaximum FlowBipartite MatchingLowest Common AncestorEulerian Path
Dynamic ProgrammingEdit Distance0/1 KnapsackUnbounded KnapsackLongest Common SubsequenceLongest Increasing SubsequenceCoin ChangeStone MergingTraveling Salesperson DPTree Dynamic ProgrammingDigit DPRerooting DP
Backtracking and SearchN-QueensSubsetsPermutationsCombination SumMaze Solving with DFSNumber of IslandsWord SearchSudoku SolverA* Search
StringsKMP String MatchingRabin-Karp String MatchingBoyer-Moore String MatchingManacher's Longest Palindromic SubstringSuffix ArrayLCP ArrayAho-Corasick AutomatonZ Function
Math and Number TheorySieve of EratosthenesLinear SieveEuclidean AlgorithmBinary ExponentiationExtended Euclidean AlgorithmChinese Remainder TheoremEuler's Totient FunctionMiller-Rabin Primality TestFast Fourier TransformPollard's Rho Factorization
Computational GeometryConvex HullRotating CalipersClosest Pair of PointsLine Segment IntersectionBentley-Ottmann Sweep Line
SearchingBinary SearchLower and Upper BoundSearch in a Rotated Sorted ArrayBinary Search on the AnswerTernary Search

Hash Table

Expected constant-time lookup by mapping keys to buckets

A hash narrows the search

A hash function converts a key into a table index. Good hashing spreads expected keys evenly, so lookup usually examines only a tiny part of the table. Distinct keys can still select the same index; this unavoidable event is a collision.

Separate chaining stores a list per bucket

Chaining keeps colliding entries together. Insertions are simple, deletion is direct once an entry is found, and the table can hold more entries than buckets. Long chains appear when the hash distribution or load factor is poor.

Try it
0
→
empty
1
→
15
8
2
→
23
3
→
empty
4
→
4
5
→
empty
6
→
empty

Enter a value and insert it to see which bucket its hash selects.

Open addressing searches the table itself

Linear probing advances through slots until it finds the key or an empty position. It avoids per-entry nodes and has strong cache locality, but dense tables create long clusters. Resizing and rehashing before the load factor becomes too high protects expected O(1) operations.

Try it
0
15
1
8
2
23
3
4
4
5
6
Load factor4/7≈ 57%

Insert a value; collisions advance one slot at a time by linear probing.

Expected, not absolute: lookup, insertion, and deletion are normally O(1), but a pathological collision pattern can degrade them to O(n).