Why is the time complexity for the worst case scenario is O(n^2)?

why is the time complexity for the worst case scenario is O(n^2) ? How to optimize this ??

Hi Arnav, In case of quick sort you can’t actually improve this O(n^2) occurs because it depends on the input given by the user.
A proper reasoning for this condition is given here.

https://stackoverflow.com/questions/4019528/quick-sort-worst-case

Hope it helps.

thanks … but this program is running fine on linux but whenever i’m trying to run it in vs code windows , then my anti-virus is treating this program file as backdoor … failed to understand why ??

Sorry I have no Idea about this. I haven’t used vscode . Although u can put it again as a doubt.