Author | Message |
---|---|
G190852562
Posts: 162
|
Posted 21:36 Dec 07, 2014 |
My questions/comments are bolded: What are connected components? 6. Following is the algorithm to find the connected components of a graph G. for i = 1 to n if i is not yet explored BFS(G, i) -- run the BFS search algorithm on node i of graph G The runtime for this algorithm is O(n^2) because we run the BFS algorithm, which is O(n), once for each node of the graph Last edited by G190852562 at
21:38 Dec 07, 2014.
|
rabbott
Posts: 1649
|
Posted 21:59 Dec 07, 2014 |
The answer is O(n) because we run the BFS algorithm, which is O(n), once for each node that wasn't touched by a previous BFS run This algorithm simply touches each node once. Hence it's O(n). The only reason the last answer is wrong is that it claims that BFS is O(1). Last edited by rabbott at
22:00 Dec 07, 2014.
|
G190852562
Posts: 162
|
Posted 22:06 Dec 07, 2014 |
I selected the last answer on my quiz. It definitely threw off my reasoning for another attempt to answer this question. |
rabbott
Posts: 1649
|
Posted 22:33 Dec 07, 2014 |
Actually, the last answer is wrong also for another reason as well. It claims that BFS is run for each node. It touches each node, but it's not run separately for each node. Last edited by rabbott at
23:19 Dec 07, 2014.
|
G190852562
Posts: 162
|
Posted 23:00 Dec 07, 2014 |
Makes sense, thanks. |
G190852562
Posts: 162
|
Posted 00:04 Dec 08, 2014 |
So what are connected components? All I know is that they're like equivalence classes. |
rabbott
Posts: 1649
|
Posted 00:19 Dec 08, 2014 |
See https://en.wikipedia.org/wiki/Connected_component_%28graph_theory%29
Last edited by rabbott at
00:19 Dec 08, 2014.
|