mercredi 1 juillet 2020

Complexity of a code in c programming language

I am wondering if the complexity of this code is O(n) or is it O(count*n)? I made the parameter count and it is not dependent on the parameter n as you could see:

void change(int A[], int n, int x)
{
  int i, j, count=0;
  for(i=0; i<n; i++)
  {
    if(A[i]==x)
     { count++; }
  }
  
  for(i=0; i<count; i++){
     for(j=0; j<n-i; j++){
         printf("Hello World"):
     }
  }
}

Aucun commentaire:

Enregistrer un commentaire