Find a theta notation for the number of times x = x +1 is executed.
for i = 1 to n
for j = 1 to n
for k = 1 to i
x = x +1
I know the answer to this is theta(n^3) but i don't understand why. I'm having trouble understanding the examples I've seen of this or similar problems, I understand that the theta of something means a function that grows similarly, but after that I get confused. If anyone could help walk me through this problem, I'd appreciate it.
for i = 1 to n
for j = 1 to n
for k = 1 to i
x = x +1
I know the answer to this is theta(n^3) but i don't understand why. I'm having trouble understanding the examples I've seen of this or similar problems, I understand that the theta of something means a function that grows similarly, but after that I get confused. If anyone could help walk me through this problem, I'd appreciate it.