I was looking for ways to say no. connected components online. I noticed that most sites use a depth search algorithm. I believe that you can achieve the same as searching in white and searching in union. So why do people prefer to use DFS to find the number of connected components?
Mostly for two reasons:
O(V)
V
O(h)
h
, node . , , . - node , Breadth-first . - , , , , , , .
, , .
Source: https://habr.com/ru/post/1687110/More articles:ambiguity in package links version - c #SFINAE when a function does not exist - c ++Unable to change git account - gitSlow DotNetCore 2.0 MVC after publication in IIS - performanceПочему "flatMap" работает с последовательностями типа Option в Scala? - scalaМетод расширения Kotlin как псевдоним для длинного имени метода? - extension-methodsHow [class] [attr] [style] directives work - angularShould every REST endpoint be asynchronous in Java EE? - javaSpecify elastics search index in payload - jsonCrash tgkill with weird weird report and no activity - javaAll Articles