Let's analyze the running time of each given function step by step.
Func1(n)
for i ← 2n to 3n do
for j ← 1 to n⌊log_2n ⌋ do
for k ← 2j+5 to 2j+8 do
s ← s + i - j + k;
The summation for Func1 can be represented as:
∑ (from i=2n to 3n) ∑ (from j=1 to n⌊log_2n⌋) ∑ (from k=2j+5 to 2j+8) 1
The inner loop for k runs 4 times (from 2j+5 to 2j+8, inclusive). The middle loop for j runs n⌊log_2n⌋ times. The outer loop for i runs n times (from 2n to 3n).
Running time T(n) = O(n * n⌊log_2n⌋ * 4) = O(n^2⌊log_2n⌋)
Func2(n)
for i ← 1 to 10⌊n^0.5⌋ do
for j ← 1 to i^2 do
s ← s + i - j;
The summation for Func2 can be represented as:
∑ (from i=1 to 10⌊n^0.5⌋) ∑ (from j=1 to i^2) 1
The inner loop for j runs i^2 times. The outer loop for i runs 10⌊n^0.5⌋ times.
Running time T(n) = O((10⌊n^0.5⌋)^3) = O(n^(3/2))
Func3(n)
for i ← 1 to 2n4 do
for j ← 5i^2+1 to 7i^2 do
for k ← 3 to 10 do
s ← s + i - j + k;
The summation for Func3 can be represented as:
∑ (from i=1 to 2n4) ∑ (from j=5i^2+1 to 7i^2) ∑ (from k=3 to 10) 1
The inner loop for k runs 8 times (from 3 to 10, inclusive). The middle loop for j runs 2i^2 times (from 5i^2+1 to 7i^2). The outer loop for i runs 2n4 times.
Running time T(n) = O(2n4 * 2 * i^2 * 8) = O(n^8)
Func4(n)
for i ← 2 to 〖2n〗^3 do
for j ← 3 to 4i^2⌊log_2i⌋ do
s ← s + i - j;
The summation for Func4 can be represented as:
∑ (from i=2 to (2n)^3) ∑ (from j=3 to 4i^2⌊log_2i⌋) 1
The inner loop for j runs 4i^2⌊log_2i⌋ times. The outer loop for i runs (2n)^3 times.
Running time T(n) = O(((2n)^3) * (4 * i^2 * ⌊log_2i⌋)) = O(n^3 * i^2 * log_i) Assuming worst-case growth, this would mean i grows at the order of (2n)^3, so that would be O(n^9 * log(n^3))
Func5(n)
for i ← n to 2n^2-1 do
for j ← 1 to i^3 do
s ← s + i - j;
The summation for Func5 can be represented as:
∑ (from i=n to 2n^2-1) ∑ (from j=1 to i^3) 1
The inner loop for j runs i^3 times. The outer loop for i runs 2n^2 - n times.
Running time T(n) = O((2n^2 - n) * i^3) Considering the worst-case growth of i as 2n^2, it runs at O(n^2 * (2n^2)^3) = O(8n^8) = O(n^8)
Please note that for a more accurate assessment of the running time, one would typically work out a more precise counting argument to simplify the bounds, ideally enforcing the loop variables to emphasize the impact of nested loops. The running times provided above are rough upper bounds based on bounding the ranges of each of the loops and are not guaranteed to be tight bounds.