Why is 6th one d??
6th one is d because the outer loop is running n times and inner nested loop is running m times so O(nm)
Think of it like this inner loop is running m times for each i so m+m+m+…(n times) which is mn or as written n*m
1 B
2 C
3 B
4 B
5 C
6 D
7 C
8 C
9 C
10 B
11 A
12 C
13 C
14 B
15 B
16 B
17 B
18 D
19 B
20 B
21 C
How to do Q 13 and Q 14 ?? Anyone Please help me to understand
For Q13, the inner loop goes ‘m’ times and the outer loop run for ‘log2(n)’ times as on each iteration the I value decreases by 2(half).
For Q14, Both the loops have a factor increase and decrease in the times of iterations by 2. Instead of running from i to n in i-=1. It goes i, i/2, i/4, i/6,…1. Similarly, j goes j, j2, j4,…m.
Hence, log2(m) * log2(n)
From other comments, 20 should be option B.
Explanation, please?
1-B
2-C
3-B
4-B
5-C
6-D
7-C
8-C
9-C
10-B
11-A
12-C
13-C
14-B
15-B
16-B
17-B
18-D
19-B
20-D
21-D
- B
- C
- B
- B
- C
- D
- C
- C
- C
- B
- A
- C
- C
- B
- B
- B
- B
- D(guess)
- D(guess)
- B
- C
The harmonic series is a divergent series. log(n) is an approximation.
- b.
- c.
- b.
- b.
- c.
- d.
- c.
- c.
- c.
- b.
- a.
- c.
- c.
- b.
- b.
- b.
- b.
- d.
- b.
- d.
- d.
Yes, I was also of the same opinion.
Yes, You are wright.
Q1: B
Q2: C
Q3: B
Q4: B
Q5: C
Q6: D
Q7: C
Q8: C
Q9: C
Q10: B
Q11: A
Q12: C
Q13: C
Q14: B(I guess)
Q15: B
Q16: B
Q17: B
Q18: D
Q19: B
Q20: B
Q21: C
Q1: B
Q1: B
Q1: B
Q1: B
Q1: B
Q1: B
Hi, can you please explain Q4?
I am not sure if you could not understand the problem or you seek the solution. I will assume that you seek the solution.
Note that ans = log (1) + log (2) + \dots + log (n) = log (n!) = \Theta (nlog (n)). For last equality : look here
1.b
2.c
3.b
4.b
5.c
6.d
7.c
8.c
9.c
10.b
11.a
12.c
13.c
14.b
15.b
16.b
17.b
18.d
19.b
20.b
21.a
1 → B
2 → C
3 → B
4 → B
5 → C
6 → D
7 → C
8 → C
9 → C
10 → B
11 → A
12 → C
13 → C
14 → B
15 → B
16 → B
17 → B
18 → D
19 → B
20 → B
21 → A
1 B
2 C
3 B
4 B
5 C
6 D
7 C
8 C
9 C
10 B
11 A
12 C
13 B
14 A
15 C
16 B
17 B
18 D
19 B
20 B
21 D