-
Anagrams
A word v is an anagram of a word v if a permutation of the letters transforming w into v exits .
anagram(string st ) => list(anagrams)
input => "below elbow car thing cried cat tac act"
returns => [['below', 'elbow'], ['car'], ['thing'], ['cried'], ['cat', 'tac', 'act']] -
Linear Search
linear_search(array,search_element) => Prints if search in array or not !
Time Complexity : O(n) where n is the no of elements in array -
Binary Search
binary_search(array,search) => prints if search in array or not !
"Needs sorted array"
Time Complexity : O(log n) where n is the no of elements in array -
Jump Search
jump_search(array,search,jump=None) => prints if search in array or not !
"Needs sorted array"
default jump = sqroot(n)
Time Complexity : O(√n) where n is the no of elements in array -
Kadane's Algorithm
kadane(array) => returns three things best_sum , start_index and end_index of subarray
Time Complexity : O(n) where n is the no of elements in the array -
Merge two Sorted Arrays
merge_sorted_array(array1,array2) => returns one sorted array
Time Complexity : O(n+m) where n, m are the no of elements in the array1 and array 2 -
Selection Sort Algorithm
Sorts the array into ascending or descending order
selection_sort(array,descending = False) => return sorted array
Time Complexity : O(n^2) where n is the no of elements in the array -
Insertion Sort Algorithm
Sorts the array into ascending or descending order
insertion_sort(array,descending = False) => return sorted array
Time Complexity : O(n^2) where n is the no of elements in the array -
Bubble Sort Algorithm
Sorts the array into ascending or descending order
bubble_sort(array,descending = False) => return sorted array
Time Complexity : O(n^2) where n is the no of elements in the array -
Dijkstras Algorithm
Uses the greedy approach to find the shorted path from source to destination in a graph
Time Complexity : O((V + E) log V) where V are the no of nodes in the graph and E are the edges of each Node.
yash9323/Algorithms-with-python
Folders and files
| Name | Name | Last commit date | ||
|---|---|---|---|---|