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.
 Algorithm Recurrence Relation
 P. Binary Search IV. T (n) = T (n/2) + 1
 Q. Merge Sort III. T (n) = 2T (n/2) + cn
 R. Quick Sort I. T (n) = T (n-k) + T (K)
 S. Tower of Hanoi II T (n) = 2T (n-1)+1
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 A
Rate difficulty Rate difficulty:
Choose a difficulty.

x = n/logn
y = logn
we get O(n/logn * logn * log logn)
So O (n log 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 A
Rate difficulty Rate difficulty:
Choose a difficulty.

Merge sort has lowest worst – case complexity, i.e. O(n log n), whereas all remaining three has O(n2)
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.
Found this useful?
Follow:

Recurrence relation for merge sort
T (n) = 2 T (n/2) + n
So T (n) = O(n logn)
but instead of integers whose comparison take O(1) time, we are given n strings so to compare strings we need O(n) time hence complexity is Q(n2 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 C
Rate difficulty Rate difficulty:
Choose a difficulty.

Given: n numbers
To find: Tightest upper bound on number of swaps required to sort n numbers using selection sort.
Analysis: In selection sort, in the unsorted part of the array, we find the minimum element and swap it with the value placed at the index where the unsorted array starts.
Hence, for each element to put it in its sorted position, we will do some swaps. In each iteration, when we find the minimum and place it in its sorted position, we do only one swap. There are n such iterations, since maximum number of positions to sort is n.
Hence, there are n.O(1) swaps
⇒ O(n) swaps.
∴ The solution is (C)
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
Boost Your PreparationAttempt mock tests, previous year papers and topic-wise quizzes.Explore All Tests →