Who said you that log base 2 of n= log base 10 of n

1- B

2- C

3 B

4- B

5- C

6- C

7 -C

8- C

9 -C

10 -B

11- A

12- C

13 -C

14 -A

15

16 -B

17 -B

18- D

19

20 - B

21-D

I think 17 should be O(n)? Worst case if all the elements are equal to x.

For \log(n) we should write upperbound and lowerbound kind of binary search.

He is right. \log_2n \ne log_{10}n, but you can certainly say \mathcal O(\log_2n) = \mathcal O(\log_{10}n). Just like how you would say, \mathcal O(2n) = \mathcal O(n). So theoretically speaking, A, B, C all are right for Q12.

If the options were \theta(\log_bn) instead, then only b = 10 will be right.

You are right. If there was such an option, we would choose it. But as there isnât one, consider this:

Hence,

Or,

As the option \mathcal O(n \log n) is available, we choose it. Doesnât mean you are wrong, \mathcal O(\log (n!)) is also right.

Answers-

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

Q15-B

Q16-B

Q17-C

Q18-D

Q19-B

Q20-B

Q21-C

Well Explaned and correct

it is n +n/2+2/3+n/3+n/4âŠ+n/n = n(1/1+1/2+1/3+âŠ+1/n) = nlogn

in bracket, there is a harmonic series which converges to logn.

so, nlogn should be the ans.

How did you arrive at option B for ques 17? I got C. Could you please explain?

- List item

question option

Q1 B

Q2 C

Q3 D

Q4 B

Q5 C

Q6 C

Q7 C

Q8 C

Q9 C

Q10 B

Q11 A

Q12 D

Q13 C

Q14 B

Q15 C

Q16 B

Q17 B

Q18 D

Q19 B

Q20 B

Q21 C

O(n)

Answer to the 6th qs would be O((nm) + n) which ofc is O(n*m)âŠright? That plus n factor because even the outer loop contains statements that would be executedâŠright?

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 C (No idea, guessed)

16 B

17 B

18 D

19 B

20 B

21 C

It is known as Optimized Ecliudean Algorithm, it is a recursive function which finds the mod of the second term( greater term) by smaller term which results in O(log n) time, that is the reason it swaps the terms if a<b in the first condition, so the we donât have to subtract repeatedly to find the gcd.

1 (B)

2 Â©

3 (A)

4 (B)

5 Â©

6 (D)

7 Â©

8 Â©

9 Â©

10 (B)

11 (A)

12 Â©

13 Â©

14 (B)

15 (B)

16 (B)

17 (B)

18 (D)

19 (B) not sure about this

20 (D)

21 Â©

- O(nlogn)
- O(n**2)
- O(logn)
- O(n**2)
- O(n+m)
- O(n*m)
- O(n**2)
- O(n**2)]
- O(n**2)
- O(n
*m*k) - O (log n)
- O(log 10 n)
- O(m log n)
- O(log m log n)
- O(log n)
- O(log n)
- O(log n)
- O(2**n)
- O(log n)

20.O(n**2) - O(nlogn)

O(n logn)

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 c

18 d

19 b

20 b

21 a

can you explain q-6 and q-19?