Avatto > UGC NET COMPUTER SCIENCE > PRACTICE QUESTIONS > Data Structures and Algorithms > Performance Analysis of Algorithms and Recurrences

Data Structures and Algorithms MCQ - Performance Analysis of Algorithms and Recurrences

Correct AnswerOption B
Rate difficulty Rate difficulty:
Choose a difficulty.

Here foo(1) is recursive function. Spare complexity is O (n) as there can be at most O (n) active function at a time
Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *

Correct AnswerOption B
Rate difficulty Rate difficulty:
Choose a difficulty.

Space complexity is O (n). The space we need array of size O (n). The space required for recursive call would be O (1) as the value would be taken from array again & again
Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *

Correct AnswerOption C
Rate difficulty Rate difficulty:
Choose a difficulty.
Share this question
Share:

If n is a power of 2, then
term
If n is not a power of 2, then there will be minor differences of 1 at wherever is odd.
Hence val(j) computed on the basis of n = 2n will give a fair answer

= 2(n – 1) = θ(n)
Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *

Correct AnswerOption B
Rate difficulty Rate difficulty:
Choose a difficulty.

T(n) = 2T(√n) + 1
Put n = 2k
T(2k) = 2T(nk/2) + 1
replace T(2k) by S(k)
S(k) = 2 S(k/2) + 1
Apply masters
Klog22 ⇒ k > 1
So Θ(k)
Now we know n = 2k, k = log2(n)
then Θ(logn)
Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *

Correct AnswerOption D
Rate difficulty Rate difficulty:
Choose a difficulty.

Since, j increases in power of 2's.
if statement j = j * 2 executes k times, then
2k < n
⇒ k < log2 n
Since k will be integer,
total number of comparison
(when loop exits)
Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *

Why Practice with Avatto?
High Quality MCQsExam-focused questions with accurate answers
Detailed ExplanationsStep-by-step explanations to enhance learning
Latest Exam PatternBased on updated syllabus and pattern
Performance AnalyticsTrack performance and improve weak areas
100% Free PracticePractice unlimited questions for free