0

I wanted to know the general run time of these 2 separate programs. I've been struggling with method of computing them.

problem 1

y = 0.5;

for (j = 0; j < N; j = j + y) {
  operation();
  y = 2*y;
}

problem 2

s1 = 1;
s2 = 1;
for (i = 1; i <= N; i++ ) {
  for (j = 0; j < s2; j++) {
    operation();
  }
  x = s1 + s2;
  s1 = s2;
  s2 = x;
}
Hovercraft Full Of Eels
  • 283,665
  • 25
  • 256
  • 373

0 Answers0