0% found this document useful (0 votes)
12 views

algorithm_properties

Jjjoutgg

Uploaded by

shivansh1479s
Copyright
© © All Rights Reserved
Available Formats
Download as XLSX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

algorithm_properties

Jjjoutgg

Uploaded by

shivansh1479s
Copyright
© © All Rights Reserved
Available Formats
Download as XLSX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Algorithm

Time Complexity
Time Complexity
(Best)
Time Complexity
(Average)
Space
(Worst)
Complexity
Advantages
Disadvantages
Binary Sea O(1) O(log n) O(log n) O(1) Efficient foOnly works on sorted arrays
Bubble SorO(n) O(n^2) O(n^2) O(1) Simple to Inefficient for large lists
Selection SO(n^2) O(n^2) O(n^2) O(1) Simple to Inefficient for large lists
Insertion SO(n) O(n^2) O(n^2) O(1) Good for neInefficient for large lists
Merge SortO(n log n) O(n log n) O(n log n) O(n) Stable, Di Uses extra space
Quick Sort O(n log n) O(n log n) O(n^2) O(log n) Efficient o Worst case is quadratic
Heap Sort O(n log n) O(n log n) O(n log n) O(1) Efficient foNot stable
Radix Sort O(nk) O(nk) O(nk) O(n + k) Fast for in Only works on integers
Dijkstra’s O(E + V logO(E + V logO(E + V logO(V) Efficient f Doesn't handle negative weights
Floyd-WarsO(V^3) O(V^3) O(V^3) O(V^2) Handles allHigh time complexity
Kruskal's AO(E log V) O(E log V) O(E log V) O(E + V) Finds MST R e equires sorting of edges
Prim's Alg O(E + V logO(E + V logO(E + V logO(E + V) Finds MST R e equires a connected graph
DFS (DepthO(V + E) O(V + E) O(V + E) O(V) Works withCan be memory-intensive for large graphs
BFS (BreadtO(V + E) O(V + E) O(V + E) O(V) Finds shor May explore unnecessary paths

You might also like