edited by
1,502 views
1 1 vote

Is there Any short cut to do these questions fast ?

Consider the following code
\[
\begin{array}{l}
\text { sum }=0 ; \\
\text { for }(\mathrm{i}=1 ; \mathrm{i} \leq n ; \mathrm{i}++) \\
\quad \text { for }\left(\mathrm{j}=1 ; \mathrm{j} \leq \mathrm{i}^{*} ; \mathrm{j}+++\right) \\
\quad \text { for }(\mathrm{k}=1 ; \mathrm{k} \leq \mathrm{j} ; \mathrm{k++}) \\
\quad \operatorname{iff}(\mathrm{j} \% \mathrm{i}=0) \text { sum++; }
\end{array}
\]

What is the complexity of the above code?
(a) $\theta\left(\mathrm{n}^{2}\right)$
(b) $\theta\left(\mathrm{n}^{3}\right)$
(c) $\theta\left(\mathrm{n}^{4}\right)$
(d) $\theta\left(\mathrm{n}^{5}\right)$

  1. A
  2. B
  3. C
  4. D
    Answer: D,

1 Answer

Position:
Show:

Related questions

3 3 votes
1 1 answer
2.4k
2.4k views
Prince Sindhiya asked Oct 23, 2018
2,372 views
Anand want to send a Love Letters(LL) to his girlfriend. Due to confidentiality problems he was used only combination of either '0' or ' 1 ' characters. He also maintaine...
1 1 vote
1 1 answer
997
997 views
Prince Sindhiya asked Oct 23, 2018
997 views
What is the time complexity of the following code?int fun1(int $x$, int $y$ )\{ if(x == 0)return y;elsereturn fun1(x-1, x + y);} $O\left(x^{2}\right)$$\mathrm{O}(\mat...
1 1 vote
0 0 answers
979
979 views
Prince Sindhiya asked Oct 23, 2018
979 views
Assume that the following timings were taken of three algorithms as they processed lists of integers.\begin{tabular}{|c|c|c|c|}\hline \begin{tabular}{c}Type of \\algorith...
0 0 votes
1 1 answer
945
945 views
Overflow04 asked Oct 9, 2022
945 views
how O($n^{2}$) in the last.(in the given solution).Q. 19Have any Doubt ?We are trying to determine the worst case time complexity of a library function that is provided t...