MathB.in
New
Demo
Tutorial
About
for ( i = 1 to n )
for( j = 1 to $\lfloor i/2\rfloor$ )
x++
n
i
$\lfloor i/2\rfloor$
j
#exec
1
1
0
0
0
2
2
1
2*1
2
3
3
1
3*1
3
4
4
2
4*2
8
5
5
2
5*2
10
6
6
3
6*3
18
7
7
3
7*3
21
8
8
4
8*4
32
The number of executions looks very logarithmic to me, but it seems that the number of times x is incremented is $n * \lfloor (n/2)\rfloor$. Does that mean the function is running in $\Theta(n^2)$ or did I make a miscalculation?
ERROR: JavaScript must be enabled to render input!
Fri, 16 Nov 2012 03:12 GMT