I got asked this in an interview and was told that O(n^2) is possible. Anyone has a simple approach for that?
Found here a paper telling me that it is as hard as matrix multiplication: http://kam.mff.cuni.cz/~matousek/cla/tria-mmult.pdf
I got asked this in an interview and was told that O(n^2) is possible. Anyone has a simple approach for that?
Found here a paper telling me that it is as hard as matrix multiplication: http://kam.mff.cuni.cz/~matousek/cla/tria-mmult.pdf
http://en.wikipedia.org/wiki/Triangle-free_graph
Testing if a graph is triangle-free would be solved by a solution for that problem. O(n^2) should have been a mistake from the interviewers' side.
Proved lower bound for triangle listing algorithm is O(n^3) or O(m^1.5), here n is the number of vertices and m is the number of edges. If you want to solve triangle counting with Matrix Multiplication method, the time complexity is same as Matrix Multiplication.
You should list more details of your question. Maybe the graph has some special property.