Given two sorted lists of size m and n respectively. The number of comparisons…

2017

Given two sorted lists of size m and n respectively. The number of comparisons needed in the worst case by the merge algorithm will be:

Answer: A. m + n − 1Correct Answer: m + n − 1 Explanation: Merge process: Repeatedly compare the smallest remaining elements of the two lists and move the smaller one into the…

  1. A.

    m + n − 1

  2. B.

    mn

  3. C.

    max (m, n)

  4. D.

    min (m, n)

Attempted by 1263 students.

Show answer & explanation

Correct answer: A

Correct Answer: m + n − 1 Explanation: Merge process: Repeatedly compare the smallest remaining elements of the two lists and move the smaller one into the output. Each comparison (in typical steps) causes one element to be placed into the merged list.

Explore the full course: Accenture Preparation

Loading lesson…