AP® Computer Science A glossary
Informal run-time analysis
Also called: run-time comparison
Course: AP® Computer Science A Shows up in: Unit 2: Selection and Iteration
Comparing how efficient code segments are by comparing their statement execution counts, found by tracing the iterative statements.
Appears in the course and exam description (CED): 2.12.A.1
Sequential loops add their counts; nested loops multiply them; a loop that doubles its variable runs very few times. Fewer executions for the same result means a faster algorithm.
int checks = 0;
for (int d = 1; d * d <= 36; d++) {
checks++;
}
System.out.println(checks);
Output:
6 Learn it properly, with a checkpoint 2.12 Informal Run-Time Analysis