Ask Question
21 December, 16:31

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?

+1
Answers (1)
  1. 21 December, 20:28
    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?
Find 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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers