For example, let's consider an algorithm that sorts a list of numbers.
The upper bound of an algorithm's running time, i.e., the worst-case scenario.
Consider the following nested for-loop in pseudocode:
for
Here, if
And the efficiency class is
Set up either a counter, or a timer to measure the algorithm's running time.
int x = 0;
int counter = 0;
for (int i = 0; i < n; i++)
{
for (int j = 0; j < n; j++)
{
x = x + 1;
counter++; // Increment the counter after each basic operation
}
}
Then try different values of