On Tue, Nov 24, 2009 at 1:48 PM, Arun <arunm...@gmail.com> wrote:

> Isnt it running DFS on every node?
> 1) Pick any node in the graph say n
> 2) With n as root, run DFS. While running DFS, if you visit node x, mark
> M[n,x]=1 and M[x,n]=1 (since its unidirected graph, M[i,j] will be equal
> to M[j,i] for any j,i) .
> The running time is O(k) where k is the number of nodes visited by n. Also
> have a hash finished[n]=true
>
I think running tme of DFS is O(n+e), so it will be in the worst case
O(k^2).

> 3) Repeat steps 1-2 for each node until finished[node] = true for all of
> them. Overall time is O(N^2).
>  On Mon, Nov 23, 2009 at 11:07 AM, Rohit Saraf <
> rohit.kumar.sa...@gmail.com> wrote:
>
>> Input - Edges.
>> Data Struct. - You decide !
>> Output - Transitive Closure in adjacency matrix.
>> order - O(n^2) .
>>
>> (Transitive closure => If 2 points i and j are connected (though not
>> directly) in the graph, then they are directly connected in the
>> closure.)
>>
>> Any nice solution? (I solved using basic DP , but i think there must
>> exist a better solution)
>>
>> --
>>
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algoge...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@googlegroups.com>
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>>
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algoge...@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

--

You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.


Reply via email to