Implement Tarjan's Algorithm