10! In current competitive world, this question should be renamed to 100 must-know algorithms. Still, lets try to categorize the algorithms in 10 broad categories.
But first, learning such a small subset(only 10!) will do no good. The more you learn, the more you will stand out from the crowd.
Learning and visualizing algorithms will change the way you tackle real life situation, you will always start looking for an optimized way to do things. And that's great, that's what smart people are - LAZY, yes, they always try to do more work with minimal effort and that's optimization.
Start developing algorithmic thinking by visualizing algorithms.
This is what I will recommend IDeserve
It's a cool platform where you can visualize the algorithms and data structures within it. I feel it is largest source for algorithms which you can visualize. Its pretty cool to see algorithms being executed and animated on the fly.
Coming back to categorizing algorithms into 10 broad categories...phew...now this will take time.
Sorting Algorithm - Bubble Sort
Sorting Algorithm - Selection Sort
Sorting Algorithm - Insertion Sort
Sorting Algorithm - Merge Sort
Reverse a Linked List - Iterative
Reverse a Linked List - Recursive
Find intersection of two Linked Lists
Find intersection of two Linked Lists - O(m + n) Time Complexity and O(1) Space Complexity
Detect a loop in a linked list and find the node where the loop starts
Convert a binary tree to doubly linked list
Convert a sorted Doubly Linked List to Balanced Binary Search Tree
Count frequencies of array elements in range 1 to n
Find all permutations of a String
Binary Search in a Sorted Array
Find a Peak Element in an array
Find pivot in a sorted rotated array
Find an element in a sorted rotated array
Find element in sorted rotated array without finding pivot
Find duplicates in an integer array
Next greater element in an array
Find Majority Element in an Array
Find median of two sorted arrays
First non-repeating character in a string
Re-arrange elements in an array to put positive and negative elements in alternate order
Find the next greater number using same digits
Longest Substring with non-Repeating Characters
Find minimum cost path in a matrix
Find the length of longest increasing subsequence in an array
Find the longest increasing subsequence in an array O(n logn)
Find the length of longest bitonic subsequence in an array
Find total number of ways to make change using given set of coins
Minimum number of coins to make change
Count all possible decodings of a given digit sequence
Find increasing sub-sequence of length three having maximum product
Find increasing sub-sequence of length three having maximum product | Optimized approach
Find index of 0 to replace to get longest continuous sequence of 1s
O(n) time approach to find index of 0 to replace to get longest continuous sequence of 1s
Find an integer array corresponding to the string specifying increase-decrease transitions
Merge two sorted arrays without using extra space
Trapping Rain Water between Towers
Find Minimum Length Sub Array With Sum K
Check if a binary tree is a binary search tree
Check if two nodes are cousins in a Binary tree
Remove all nodes which lie on path having sum less than k
Binary Search tree | Insertion and Search
Binary Tree Level Order Traversal
Print bottom view of a binary tree
Print bottom view of a binary tree using level order traversal
Check if a binary tree is balanced or not
Check if a binary tree is sub-tree of another binary tree in space O(1)
Check if a binary tree is sub-tree of another binary tree in time O(n)
Check if all internal nodes of BST have only one child without building tree
Check if a given binary tree is symmetric tree or not
Check if two binary search trees are identical given their array representations
Check if two binary search trees are identical given their array representations | Set 2
Check if the given n-ary tree is symmetric tree or not
Check if two binary trees are identical
Convert a binary tree to doubly linked list
Convert a sorted Doubly Linked List to Balanced Binary Search Tree
Create a balanced Binary Search Tree from a sorted array
Check whether a binary tree is complete or not
Check whether a binary tree is a full binary tree or not
Construct binary tree from inorder and postorder traversals
Construct binary tree from inorder and preorder traversals
Construct the binary tree from its parent array representation
Convert binary tree to binary search tree
Find depth of deepest odd level leaf node
Find height of the binary tree from its parent array representation
Find sum of all left leaves of a binary tree
Find floor and ceiling of an element from given dataset using binary search tree
Recover a Binary Search Tree if positions of two nodes are swapped
In-order Successor of a Node in a Binary Tree
In-order Traversal of a Binary Tree
Print left view of a binary tree
Lowest Common Ancestor of 2 nodes in a Binary Tree
Minimum Depth of a Binary Tree
Convert a binary tree to its mirror tree
Convert the given n-ary tree to its mirror image
Trie Data Structure | Insert and search
Longest Prefix Matching using Trie
Post-order Traversal of a Binary Tree
Pre-order Traversal of a Binary Tree
Print all Root to Leaf paths of a Binary Tree
Print binary tree in vertical order
Print all nodes of a binary tree that do not have sibling
Remove all the half nodes from a given binary tree
Remove the nodes of binary search tree which are outside the given range
Print right view of a binary tree
Serialize and Deserialize a binary search tree using post order traversal
Serialize and Deserialize a binary search tree
Find the size of largest BST in a binary tree
Print top view of a binary tree using level order traversal
Print top view of a binary tree
Total number of possible Binary Search Trees with n keys
Given a sequence of words, group together all anagrams and print them
Find all permutations of a String
Find minimum edit distance between given two strings
To print maximum number of As using given four keys
Check balanced parentheses in a string
Distinct binary strings of length n with no consecutive 1s
Finding 10 letter repeated DNA sequences
First non-repeating character in a string
Group all anagrams together from a given array of strings | Set 1
Longest Palindromic Subsequence
Longest Substring with non-Repeating Characters
The longest prefix suffix array computation in KMP pattern matching algorithm
The Knuth Morris Pratt algorithm for pattern matching
Dijkstra's Shortest Path algorithm
Friend Circles Problem - Graph Theory
Topological Sorting of a Directed Acyclic Graph
Find minimum cost path in a matrix
Find total number of ways to make change using given set of coins
Minimum number of coins to make change
Find the length of longest increasing subsequence in an array
Find the length of longest bitonic subsequence in an array
Count all possible decodings of a given digit sequence
To print maximum number of As using given four keys
Find minimum edit distance between given two strings
Total number of possible Binary Search Trees with n keys
Longest Increasing Subsequence O(n logn)
Longest Palindromic Subsequence
Algorithms | Time Complexity | Space Complexity | ||
---|---|---|---|---|
Best | Average | Worst | Worst | |
QuickSort | Ω(n log(n)) | Θ(nlog(n)) | O(n^2) | O(log(n) |
Merge Sort | Ω(n log(n)) | Θ(nlog(n)) | O(nlog(n)) | O(n) |
TimSort | Ω(n) | Θ(nlog(n)) | O(nlog(n)) | O(n) |
Heap Sort | Ω(n log(n)) | Θ(nlog(n)) | O(nlog(n)) | O(1) |
Bubble Sort | Ω(n) | Θ(n^2) | O(n^2) | O(1) |
Insertion Sort | Ω(n) | Θ(n^2) | O(n^2) | O(1) |
Selection Sort | Ω(n^2) | Θ(n^2) | O(n^2) | O(1) |
Tree Sort | Ω(n log(n)) | Θ(nlog(n)) | O(n^2) | O(n) |
Shell Sort | Ω(n log(n)) | Θ(nlog(n))^2 | O(nlog(n))^2 | O(1) |
Bucket Sort | Ω(n+k) | Θ(n+k) | O(n^2) | O(n) |
Radix Sort | Ω(nk) | Θ(nk) | O(nk) | O(n+k) |
Counting Sort | Ω(n+k) | Θ(n+k) | O(n+k) | O(k) |
CubeSort | Ω(n) | Θ(nlog(n)) | O(log(n) | O(n) |