retagged by
534 views

1 Answer

Best answer
1 1 vote

Time Complexity of a loop is considered as O(n) if the loop variables is incremented / decremented by a constant amount.

For example following functions have O(n) time complexity-

// Here c is a positive integer constant   
   for (int i = 1; i <= n; i += c) {  
        // some O(1) expressions
selected by
Answer:
Position:
Show:

Related questions

0 0 votes
3 answers 3 answers
2.8k
2.8k views
Bikram asked May 26, 2017
2,765 views
Find the time complexity of the functionfunction( int n) { int i=1; while( i<n) { int j=n; while( j>0) j=j/2; i=2*i; } }$O(\log n)$$O(n^2 \log n )$$O(\log 2 n)$$O( \log n...
0 0 votes
2 answers 2 answers
1.3k
1.3k views
Bikram asked May 26, 2017
1,331 views
$O(n^k)$ is complexity of the best method that finds longest Palindrome Substring in a word. For example, in the word "Atatb", the longest palindrome string is "tat". The...
2 2 votes
1 answers 1 answer
901
901 views
Bikram asked May 26, 2017
901 views
Which of the following are TRUE?$n! = \theta ((n + 1)!)$$\log4 n = \theta ( \log2 n )$$\sqrt{\log n} = O(\log \log n)$(i) & (iii) only(i) & (ii) only(ii) only(i),(ii) ...
1 1 vote
2 answers 2 answers
1.1k
1.1k views
Bikram asked May 26, 2017
1,065 views
Which of the following theorems can solve all Recurrence Relations?Mater TehoremAkra-Bazzi TheoremBoth [A] and [B]Akra-Bazzi can be applied to some cases but not for all.