dimanche 7 décembre 2014

worst case for this code?


Vote count:

0





n = 0;
sum = 0;
cin >> x;
while (x != -999)
{
n++;
sum += x;
cin >> x;
}
mean = sum / n;


I understand how to find complexity of an algorithm. My problem is that I'm not sure if this can be solved since it relies on input. For the worst case, I think that the input never equals -999 so the worst case complexity is infinity. Is this the right way to go about this? Thanks in advance!!



asked 16 secs ago







worst case for this code?

Aucun commentaire:

Enregistrer un commentaire