Пожалуйста, прочтите новое правило об ограничении использования AI-инструментов. ×

Why does the time taken differ so much?

Правка en1, от 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?

Теги #geometry

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский RifatALmuiN 2024-07-08 12:44:14 687 Initial revision (published)