retagged by
691 views
0 votes
0 votes

PLEASE EXPLAIN HOW TO APPROACH THESE KIND OF PROBLEMS

retagged by

2 Answers

1 votes
1 votes

$F_k$ is the $k^{th}$ number, and can be calculated in $O(\log k)$.

Similarly, $F_{n^2}$ is the $(n^2)^{th}$ number, and hence can be calculated in $O(\log n^2)$, i.e $= O(\log n)$.

Both A and C are correct in terms of mathematical notation of Order of growth.

Order notation denotes a set of functions, and both above denote the same set.

When we talk about the complexity of algorithms, we keep it as simplistic as possible, avoiding unnecessary details.

1 votes
1 votes
Answer will be $O(log(n^{2}))$.

Here, $log(n^{2}) = 2logn$ which leads to $O(2logn) = O(logn)$ as you drop the constants in Big-Oh notation.

So, both A and C.

Note, too, that $O(log(n))$ is exactly the same as $O(log(n^{c}))$. The logarithms differ only by a constant factor, and the big O notation ignores that. Similarly, logs with different constant bases are equivalent.
edited by

Related questions

0 votes
0 votes
1 answer
1
2 votes
2 votes
1 answer
2
gauravkc asked Apr 5, 2018
897 views
What is the time complexity of this code?
3 votes
3 votes
1 answer
3
0 votes
0 votes
3 answers
4
pranab ray asked Jan 13, 2018
415 views
i am getting t.c as O(n^5) but given answer as O(n^4) what should be the answer