newb_ie

time and space

Aug 24th, 2021 (edited)
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. Sorting Algos :
  2. Bubble sort: Best : O(n),Average: O(n^2),worst : O(n^2)
  3. Insertion sort: Best : O(n),Average: O(n^2),worst : O(n^2)
  4. Quick Sort : Best : nlogn,Average: nlogn,worst : O(n^2)
  5. Merge Sort : Best : nlogn,Average: nlogn,worst : nlogn,space complexity : O(n)
  6. Heap Sort : Best : nlogn,Average: nlogn,worst : nlogn,space complexity : 1
  7.  
  8. Graph Theory :
  9. BFS : Time O(n + m) where n is number of node and m is number of vertices,space O(n + m)
  10. DFS : O(n) where n is the number of nodes
  11. Dijkstra : O(V+Elog2V) where V is number of vertices and E is number of edges
  12. BellmanFord : O(V*E)
  13. Prims: O(Elog(V))
  14. Kruskal : O(ElogV)
  15.  
  16. TSP : O(N^2 * 2^N)
Add Comment
Please, Sign In to add comment