Ask Question
6 April, 01:05

2. a. Write pseudocode for a divide-and-conquer algorithm for finding valuesof both the largest and smallest elements in an array of n numbers. b. Set up and solve (for n = 2k) a recurrence relation for the number of keycomparisons made by your algorithm. c. How does this algorithm compare with the brute-force algorithm for thisproblem?

+4
Answers (1)
  1. 6 April, 02:25
    0
    The pseudocode:

    Pair MaxiMini (array, sizeof_array)

    if sizeof_array = 1

    return element as both maximum and minimum

    else if sizeof_array = 2

    do one comparison to find the maximum and minimum

    return that pair

    else

    # sizeof_array > 2

    recursion for maximum and minimum of the left half

    recursion for maximum and minimum of the right half

    one comparison determines the true max of the two elements

    one comparison determines the true min of the two elements

    return the pair of maximum and minimum
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “2. a. Write pseudocode for a divide-and-conquer algorithm for finding valuesof both the largest and smallest elements in an array of n ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers