Here display function is being called recursively, but there does not seem to be any base case here. In if block inside display functionthere should be return statement somewhere for backtracking.
I am not able to understand how is it working.Pls explain me