3 ms·
The fastest algorithm for computing the sum 1 + 2 + 3 + .. + n is constant. But the result of the sum is O(n^2). You can use that result to conclude that algor
by Dewie 13y ago
The fastest algorithm for computing the sum 1 + 2 + 3 + .. + n is constant. But the result of the sum is O(n^2).
You can use that result to conclude that algorithms like for example bubble sort has a worst case running time of O(n^2), since it does (n-1) + (n-2) + ... + 1 swaps in the worst case during the whole sorting.