I am attempting to understand the growth of the following algorithm, which is described as $n^2$ growth in the book I am reading:
"... performs of the order of $n^2$ steps on a sequence of length $n$."
Could someone please explain how this is calculated in the following code, which is also taken from the book?
If I print out the statements when the lines are executed, it first executes $n$ steps, then decreases $n-1$ steps for each loop iteration until it reaches $0$. This does not seem like exponential growth to me. Why does this grow at $n^2$?
dataset = [3,1,2,7,5]
product = 0
# algorithm begins here
for i in range(len(dataset)):
for j in range(i + 1, len(dataset)):
product = max(product, dataset[i]* dataset[j])