All Exams Test series for 1 year @ ₹349 only
Question

Match List-I with List-II
 

List-IList-II
(Algorithm)(Recurrence relation)
(A).Binary Search(I). $T(n)= T(n/2) + c$ (where $c$ is a constant)
(B).Merge Sort(II). $T(n)= 2T(n/2) + \Theta (n)$
(C). Quick sort (worst case partitioning)(III). $T(n)= T(n-1) + \Theta (n)$
(D). Linear Search(IV). $T(n)= T(n-1) + c$ (where $c$ is a constant)


Choose the correct answer from the options given below:

The correct answer is
(A) - (I), (B) - (II), (C) - (III), (D) - (IV)

Matching Algorithms with Recurrence Relations

This solution explains how to match common algorithms like Binary Search, Merge Sort, Quick Sort, and Linear Search with their respective recurrence relations. Understanding these relations is crucial for analyzing the time complexity of algorithms.

Understanding Algorithm Recurrence Relations

A recurrence relation defines a function in terms of itself, often used to describe the time complexity of recursive algorithms. Let's analyze each algorithm:

(A) Binary Search Recurrence Relation

Binary Search works by repeatedly dividing the search interval in half. If the search value is less than the middle element, the search continues in the lower half; otherwise, it continues in the upper half. This process reduces the problem size by half in each step. The work done at each step (comparison and index calculation) is constant. Therefore, the recurrence relation is:

$T(n) = T(n/2) + \Theta(1)$

This matches relation (I): $T(n)= T(n/2) + c$ (where $c$ is a constant).

(B) Merge Sort Recurrence Relation

Merge Sort is a divide-and-conquer algorithm. It divides the input array into two halves, recursively sorts each half, and then merges the two sorted halves. The dividing step takes constant time. The sorting of two halves takes $2T(n/2)$ time. The merging step requires iterating through both halves, which takes linear time, $\Theta(n)$. So, the recurrence relation is:

$T(n) = 2T(n/2) + \Theta(n)$

This matches relation (II): $T(n)= 2T(n/2) + \Theta (n)$.

(C) Quick Sort (Worst Case) Recurrence Relation

In the worst-case scenario for Quick Sort, the pivot selection consistently results in one subproblem containing $n-1$ elements and the other containing $0$ elements. This typically happens when the array is already sorted or reverse-sorted, and the first or last element is chosen as the pivot. The partitioning step still takes linear time, $\Theta(n)$. Thus, the recurrence relation becomes:

$T(n) = T(n-1) + T(0) + \Theta(n)$

Since $T(0)$ is a constant, this simplifies to:

$T(n) = T(n-1) + \Theta(n)$

This matches relation (III): $T(n)= T(n-1) + \Theta (n)$.

(D) Linear Search Recurrence Relation

Linear Search checks each element of a list sequentially until the target element is found or the list ends. If we consider a recursive implementation, it checks the first element. If it's not the target, it recursively searches the remaining $n-1$ elements. The check takes constant time, $\Theta(1)$. The recurrence relation is:

$T(n) = T(n-1) + \Theta(1)$

This matches relation (IV): $T(n)= T(n-1) + c$ (where $c$ is a constant).

Summary of Matches

Here is a summary table showing the correct matches between the algorithms and their recurrence relations:

Algorithm List-I Identifier Recurrence Relation List-II Identifier
Binary Search (A) $T(n)= T(n/2) + c$ (I)
Merge Sort (B) $T(n)= 2T(n/2) + \Theta (n)$ (II)
Quick Sort (worst case) (C) $T(n)= T(n-1) + \Theta (n)$ (III)
Linear Search (D) $T(n)= T(n-1) + c$ (IV)

Final Correct Matching

Based on the analysis, the correct matching is:

  • (A) - (I)
  • (B) - (II)
  • (C) - (III)
  • (D) - (IV)

This corresponds to Option 1.

Was this answer helpful?

Important Questions from Miscellaneous

  1. Which of the following scheduler/schedulers is/are also called CPU scheduler ?
    (A). Short Term Scheduler
    (B). Long Term Scheduler
    (C). Medium Term Scheduler
    (D). Asymmetric Scheduler
    Choose the correct answer from the options given below:
  2. A situation where two or more processes are blocked, waiting for resources held by each other is called:
  3. External fragmentation occurs ________.
  4. Which disk scheduling algorithm looks for the track closest to the current head position?
  5. Which CPU scheduling algorithm prefers the process with the shortest burst time?
Need Expert Advice?

Start Your Preparation with Prepp Mobile App

Download the app from Google Play & App Store
Download the app from Google Play & App Store
Prepp Mobile App