edited by
799 views
1 votes
1 votes

Find the time complexity?

for(i=1;i<=n;i++)
{
  for(j=1;j<i;j++)
  {
    if((i℅j)==0)
    {
      for (k=1;k<=n;k++)
      {
        sum+=k;
      }
    }
  }
}

 

edited by

3 Answers

0 votes
0 votes
$\sum_{i}^{n}\sum_{j}^{i}\sum_{k}^{n} O\left ( 1 \right )$

$=\sum_{i}^{n}\sum_{j}^{i}O\left ( n\right )$

$=\sum_{i}^{n}T\left ( i \right )O\left ( n\right )$

$=\left ( 1+2+3....+n \right )O\left ( n\right )$

$=O\left ( n^{2} \right )O\left ( n\right )$

$=O\left ( n^{3} \right )$

Related questions

0 votes
0 votes
0 answers
1
Subbu. asked Jan 15, 2022
253 views
The time complexity of Build heap using linked list and Binary search tree construction using linked list????.Need some detailed explanation
0 votes
0 votes
0 answers
2
BHOJARAM asked Dec 17, 2021
490 views
Consider all the elements of an array is same and choosing pivot such a way that divides array into two equal parts. Then will it behave like QuickSort best case or worst...
0 votes
0 votes
0 answers
3
Ansh Sinha asked Jan 7
142 views
In CRC, if the dataword is 5 bits and the codeword is 8 bits, how many 0s need to be added to the dataword to make the dividend? What is the size of the remainder? What i...
0 votes
0 votes
0 answers
4
Dknights asked Dec 10, 2023
109 views
‘either or’ can be taken as union in discrete mathematics?