Tracing loops: 4.5.1

  • Tracing tables are useful to keep track of variables
    • Useful when loops have multiple

Counting loop iteration: 4.5.2

  • Loops can be analyzed to determine how many times they run
    • run-time analysis
    • a statement execution count
  • A loop will execute (largestValue - smallestValue) + 1 times
    • if a loop uses counter <= limit, limit is the largest value
      • counter < limit, limit-1 is the largest value

Nested loop iterations

  • A nested for loop body executes can be found with a standard formula
    • outer loop iteration * inner loop iterations

Summary: 4.5.4

  • A trace table can be used to keep track of variables and their values
    • Useful when tracking loop iterations
  • The number of times a segment will execute is determined with a statement execution count
    • This process is run-time analysis
  • The number of times a loop executes is determined by
    • (largestValue - smallestValue) + 1
  • The number of times a nested loop runs is determined by
    • outer loop iterations * inner loop iterations