9956c1ff60
Kruskal’s algorithm to find the minimum cost spanning tree uses the greedy approach. The Greedy Choice is to pick the smallest weight edge that does not cause a cycle in the MST constructed so far. Time Complexity: O(ElogE) or O(ElogV), Sorting of edges takes O(ELogE) time. After sorting, we iterate through all edges and apply the find-union algorithm. The find and union operations can take at most O(LogV) time. So overall complexity is O(ELogE + ELogV) time. The value of E can be at most O(V2), so O(LogV) is O(LogE) the same. Therefore, the overall time complexity is O(ElogE) or O(ElogV) Auxiliary Space: O(V + E), where V is the number of vertices and E is the number of edges in the graph |
||
---|---|---|
.. | ||
arrays | ||
dictionaries | ||
dynamic_programming | ||
graphs | ||
linked_lists | ||
multiplication | ||
number_theory | ||
queues | ||
recursion | ||
scheduling | ||
searching | ||
sorting | ||
strings | ||
trees | ||
README.md |
README.md
Python
Arrays
- Count Inversions
- Majority Element
- Rotate Array
- Missing Number
- Remove duplicate items
- Dutch National Flag Algorithm
Linked Lists
Dictionaries
Multiplication
Recursion
- Factorial
- n-th Fibonacci number
- Recursive Insertion Sort
- Recursive Sum of n numbers
- GCD by Euclid's Algorithm
Scheduling
Searching
- Binary Search
- Jump Search
- Linear Search
- Ternary Search
- Interpolation Search
- Uniform Cost Search
- Breath First Search
Sorting
- Bubble Sort
- Comb Sort
- Count Sort
- Insertion Sort
- Quicksort
- Selection Sort
- Heap Sort
- Radix Sort
- Shell Sort
- Merge sort
Strings
- Is Good Str
- Palindrome
- Word Count
- Remove Duplicates from a String
- First Non Repeating Character
- Longest Common Subsequence
- Unique Character
- Add String
- Rabin Karp algorithm
- Find all permutations
Dynamic Programming
- Print Fibonacci Series Up To N-th Term
- Sum Up To N-th Term Of Fibonacci Series
- N-th Term Of Fibonacci Series
- Catalan Sequence
- 0/1 Knapsack Problem
- Levenshtein distance