Solution for Section 6.2 Question 4

4. a) The outer loop is iterated 4 times. During each iteration of the outer loop, the middle loop is iterated 3 times.  During each iteration of the middle loop, the inner loop is iterated 5 times. Hence the inner loop will be iterated a total of   4 · 3 · 5 = 60 times.

b) In this case, each loop is iterated n times. Hence the inner loop will be iterated a total of  n · n · n = n3 times.

Back to Section 6.2