I am not able to understand the explanation given in the answers.Can you please help me with these questions
Please explain in detail.
Please explain answers for ques 5, 11, 14
Q-5 At every step, there are two cases
b >= a / 2, then a, b = b, a % b will make b at most half of its previous value
b < a / 2, then a, b = b, a % b will make a at most half of its previous value, since b
is less than a / 2
So at every step, the algorithm will reduce at least one number to at least half less. In at most O(log2a)+O(log2b) step, this will be reduced to the simple cases. Which yield an O(log2n) algorithm, where n is the upper limit of a and b.
Q-11 https://stackoverflow.com/questions/2095395/is-logn-Θn-logn
Q-14
log time the function will execute
and time complexity of pow will be log time
hence log log N