Observing a new node cannot form a circle if it is linked to a non circular node visited before, the algorithm can be improved from an O(n^2) algorithm to O(n) algorithm.