I had a doubt in computing the time complexity in the following snippet.
Case 1:- for (i = n; i>=1 ; i=i/2) printf("%d", i);
Case 2:- for (i = 1; i < n; i=i*2) printf("%d", i)
Can I tell, the above codes, will take O(N/2) or O(log N) time complexity to run against the input?
Thanks in advance.
n, how many lines do you get? Does the number of lines seem to be proportional tolog n?