The Universal Code Encyclopedia for Python, JavaScript, C++, Java, C#, and Go.
Determine if a number is prime using the efficient O(ān) method.
Loading featured code...
Prime, Factorial, GCD, LCM, Fibonacci, and Power algorithms.
Bubble Sort, Quick Sort, and Merge Sort implementations.
Reverse String and Palindrome Check across all 6 languages.
Linear Search and Binary Search across all 6 languages.
Insert, Delete, Reverse, Find Max and Min operations.
Recursive Factorial, Fibonacci, and Tower of Hanoi.
LIFO structure ā Push, Pop, and Peek operations.
FIFO structure ā Enqueue and Dequeue operations.
Insert, Delete, Search, and Traverse a singly linked list.
Grid traversal in all 6 directions ā horizontal, vertical, and all 4 diagonals.
Big O notation describes how an algorithm's runtime or memory usage grows as the input size n increases. It measures the worst case ā how slow can it get?
Lower is always better. An O(1) algorithm runs in the same time whether n=10 or n=1,000,000. An O(n²) algorithm on 1,000 items does 1,000,000 operations.