+ 3

C++ time complexity between sort() and manual sorting with loops

In C++ , 1.Using the sort() functions and 2.Using loops to manually sort an array. Which is having more time complexity?And will anyone tell me How to calculate any time complexity?

24th Jul 2020, 2:47 AM
R Vijay Anand
R Vijay Anand - avatar
2 Antworten
+ 3
std::sort usually uses QuickSort or a in some cases another version of it , IntroSort. The worst-case time complexity in terms of Big O notation for Quick-Sort is O(n^2). Manual Sort depend on the algorithm you use. Refer here for time Complexity of other algorithms: https://www.geeksforgeeks.org/analysis-of-different-sorting-techniques/
24th Jul 2020, 2:53 AM
Saphal Poudyal
Saphal Poudyal - avatar
+ 2
Thank you Ćheyat for your valuable response🙏 Happy coding 😀
25th Jul 2020, 2:10 AM
R Vijay Anand
R Vijay Anand - avatar