I am reading a problem that I've encountered here with its corresponding solution. The statement is the following:
Given coordinates of a source point (x1, y1) determine if it is possible to reach the destination point (x2, y2). From any point (x, y) there only two types of valid movements: (x, x + y) and (x + y, y). Return a boolean true if it is possible else return false.
I understand how the recursion works for this problem but I was thinking how it works in terms of the complexity. I am thinking about the worst case which is starting from (1,1) to arrive to an arbitrary (x,y) - how many recursive calls are there in this case ? I am having difficulty trying to calculate the number of recursive calls so I would really appreciate an explanation or illustration on the number of calls that there would be. Thanks in advance
O(n)algorithm and hints at anO(log(n))one. But as Yuri says, the big-O notation is about algorithms and not problems.