A repo of Data Structures and Algorithms concepts with JavaScript.
Name/Complexity | Worst Case | Average Case | Best Case | Space Complexity | Stable |
---|---|---|---|---|---|
1. Insertion Sort | O(n^2) | O(n^2) | O(n) | O(1) | Yes |
2. Bubble Sort | O(n^2) | O(n^2) | O(n) | O(1) | Yes |
3. Selection Sort | O(n^2) | O(n^2) | O(n^2) | O(1) | No |
4. Merge Sort | O(nlogn) | O(nlogn) | O(nlogn) | O(n) | Yes |
5. Quick Sort | O(n^2) | O(nlogn) | O(nlogn) | O(n)/O(logn) | No |
5a. Random Quick Sort | O(nlogn) | O(nlogn) | O(nlogn) | O(logn) | No |
6. Counting Sort | O(n+k) | O(n+k) | O(n+k) | O(n+k) | Yes |
7. Radix Sort | O(d*(n+b)) | O(d*(n+b)) | O(d*(n+b)) | O(n+b) | Yes |
n = length of input array
k = range of input elements
d = number of digits in largest element
b = base Size (10 for decimals)
- Factorial of n
- Summation of numbers from 1 to n
- Base Conversion
- Exponentiation of a number
- Prime Factorization
- Greatest Common Divisor
- Fibonacci Series
- Divisibility Check by 9 and 11
- Tower of Hanoi
- Linear Search (Sequential Search)
- Binary Search
- Traversal in BST
- Searching in BST
- Finding Nodes with Max. and Min. Value
- Insertion in BST
- Deletion in BST