I'm stuck with nested for loops that are dependent on the previous loop:
for (i=1; i<=n; i++) for (j=1; j<=i; j++) x = x+1
the part that is confusing me is
I'm trying to figure out the asymptotic running time.
Computer Science Stack Exchange is a question and answer site for students, researchers and practitioners of computer science. It only takes a minute to sign up.Sign up to join this community
Suppose that you start with some value in $x$. The inner loop increases $x$ by $i$. Therefore the outer loop increases $x$ by $1+2+3+\cdots+n = n(n+1)/2$. So overall, your code increases the value in $x$ by $n(n+1)/2$.
The running time of your code is proportional to the number of times that $x$ is increased, hence it is $\Theta(n^2)$.