Блог пользователя rahul_1234

Автор rahul_1234, история, 10 лет назад, По-английски

Given 'n' circles (each defined by center and radius) Write an algorithm to detect if given circles intersect with any other circles in the same plane

Better than O(n^2) complexity

  • Проголосовать: нравится
  • +16
  • Проголосовать: не нравится

»
10 лет назад, скрыть # |
← Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

If I got the problem correctly, for each circle you just need to loop though all others and compare the distance between two centers versus the sum of two radiuses. Two circles intersect if the former is not greater than the latter.

The time complexity for the above approach would be O(n^2) ______

Updated 1: Sorry the time complexity is not good enough

»
10 лет назад, скрыть # |
 
Проголосовать: нравится +10 Проголосовать: не нравится

Do I have to say whether there are 2 circles that intersect or the pairs of circles that intersect?