Please read the new rule regarding the restriction on the use of AI tools. ×

Why does the time taken differ so much?

Revision en1, by RifatALmuiN, 2024-07-08 12:44:14

First one (2027 ms): 253857814
The second one (249 ms): 253859120

In my observation, both of them have a time complexity of O(n2logn2)

  • First one: I created a vector of pairs that have a size of nearly n2 and inserted all of them in a map which will take O(n2logn2) time complexity.
  • Second one: I created a vector of pairs with a similar size of nearly n2. And I then sorted it which will take O(n2logn2) time complexity.

Then why the second approach is taking so much less time?

Tags #geometry

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English RifatALmuiN 2024-07-08 12:44:14 687 Initial revision (published)