The question has been updated on 19/01/2020
n1 = outer loop
n2 = inner loop
Inner loop execution only = 1
= [Outer Loop] 2 ∗ (n + 1) + 2(n)
[Inner Loop] (n * 2)
= 2 * (5 + 1) + 2(5) + (5 * 2)
= 2 * 6 + 10 + 10
= 12 + 10 + 10
= 32
I am wondering how to get 22 for the outer loop.
I can only get a maximum of 12 for the outer loop.
Am I counting it wrongly?
for (int i = 1; i < input.length; i++) { // 2 costs * 4
int key = input[i]; // 1 cost * 4
...
}
And the explanation said that the “The inner loop will never run any iterations”, really?
Would you please explain how to get 32 for this question?