I have a graph with n
nodes as an adjacency matrix.
Is it possible to detect a sink in less than O(n)
time?
If yes, how? If no
There are so many algorithms that shows how to find the universal sink in O(n) but they are so complex and couldn't be understood easily. I have found it on internet in paper that shows how to find a universal sink in O(n) very smoothly.
1) first create a "SINK" set consisting of all vertices of the graph also
create an adjacency list of the graph.
2) now choose first 2 elements of the set.
3) if(A(x,y)==1){
remove x; // remove x from "SINK" set.
}else{
remove y; } //remove y from "SINK" set.B
By this algo you will end up with the sink node in your SINK set in "n-1" time. that is O(n) time.