this repo will have basic sorting algorithms and data structures code
- Bubble Sort - time complexity is O(n^2)
- Selction Sort - time complexity is O(n^2)
- Insertion Sort - Whenever we move element, make sure left side of the elements should be sorted and also time complexity is O(n) when you have most of the elements are sorted- O(n^2)
TimeComplexity Name Example
1 Constant Insertion/Deletion from LinkedList
log^n Logarithmic Finding an element in Sorted Array
n Linear Finding an element in UnSorted Array
nlog^n LinearLogarithmic Sorting items by "Divide and Conquer"- Merge Sort
n^2 Quadratic Shortest path between two nodes in a graph
n^3 Cubic Matrix Multiplication
2^n Exponential The Tower of Hanoi problem
A. Search
-
UnOrdered List
a. Best case, knowing the index of the element that you then it is O(1)
b. Worst case, O(n) -
Ordered List a. O(log^n base2)
B. Insertion/Deletion
- Ordered list
a. Worst case, O(n)
b. Best case, O(1)