Homework Solution: Disclaimer: This is just One question with multiple parts. It is not multiple questions in one post. Question:…

    Disclaimer: This is just One question with multiple parts. It is not multiple questions in one post. Question: Consider the problem of finding both the maximum and the minimum. We will show that you can not find them both in less than (about) 3n/2 comparisons. Consider the run of any algorithm and defined the following sets that depend on the comparison the algorithm chose. Let N be the collection of numbers. We denote n = |N |. After comparisons were done, let W be all numbers that only ”won” (always were larger) in all the comparisons, and let its size be w. Let L be the set of numbers who always ”lost” and lets its size be `. Let B be the set of those who both lost least once and won at least once. 1. Show that there is always an input so that if a member u ∈ W is compared to a number not in W , u wins. 2. Show that there is an input so that if a member u ∈ L is compared to a number not in L, u looses. 3. Show that when the algorithm stops, there is exactly one element in W , exactly one element in in L and the rest of the elements belong to B. 4. Recall that n = |N |, w = |W |, ` = |L|, and consider 3n + 2w + 2`. Show that at start the value is 3n and at the end at the end its 4 5. Show that the number of comparisons needed to find the maximum and the min- imum in the worst case (only using comparisons) is at least d(3n − 4)/2e.

    Expert Answer

     
    1. Show that there is always an input so that if a member u ∈ W i

    Disclaimer: This is equitable Individual doubt with multiple volume. It is referable multiple doubts in individual post.

    Question:

    Observe the example of confutation twain the utmost and the poverty. We
    accomplish demonstration that you can referable ascertain them twain in less than (about) 3n/2 comparisons.

    Observe the ooze of any algorithm and defined the subjoined firms that pause on the
    comparison the algorithm chose. Suffer N be the store of collection. We play n = |N |. After comparisons were performed, suffer W be entire collection that simply ”won” (constantly were larger) in entire the comparisons, and suffer its largeness be w. Suffer L be the firm of collection who constantly ”lost” and suffers its largeness be `. Suffer B be the firm of those who twain obsolete smallest unintermittently and acquired at smallest unintermittently.

    1. Demonstration that there is constantly an input so that if a portion u ∈ W is compared to a
    enumerate referable in W , u enlists.

    2. Demonstration that there is an input so that if a portion u ∈ L is compared to a enumerate
    referable in L, u looses.

    3. Demonstration that when the algorithm seals, there is correspondently individual atom in W , correspondently
    individual atom in in L and the intermission of the atoms suit to B.

    4. Recentire that n = |N |, w = |W |, ` = |L|, and observe 3n + 2w + 2`. Demonstration that at
    start the prize is 3n and at the object at the object its 4

    5. Demonstration that the enumerate of comparisons needed to ascertain the utmost and the min-
    imum in the overcome fact (simply using comparisons) is at smallest d(3n − 4)/2e.

    Expert Confutation

     

    1. Demonstration that there is constantly an input so that if a portion u ∈ W is compared to a enumerate referable in W , u enlists.

    Now if we observe that u loses to a enumerate (repeat num) referable in W then num can’t be keep-akeep-apart of L as L has portion which constantly obsolete. Also there constantly insist individual enumerate in B which would entertain obsolete to a enumerate in W.

    So this dissent our arrogance and hereafter there constantly insist such a enumerate in w

    2. Demonstration that there is an input so that if a portion u ∈ L is compared to a enumerate referable in L, u looses.

    Now suffers observe that u enlists when compared with enumerate referable in L.

    u can’t enlist with enumerate in W as enumerate of w constantly acquired. Also there constantly insist a enumerate in L which would entertain obsolete to entire enumerate in B.

    Hereafter this dissent our arrogance and hereafter such a enumerate insist.

    3.

    Demonstration that when the algorithm seals, there is correspondently individual atom in W , correspondently individual atom in in L and the intermission of the atoms suit to B.

    When algorithm seal, suffer there are brace enumerate in W. This media that these brace collection which were never compared differently individual of them accomplish referable sojourn in w. So this can’t supervene and hereafter there accomplish be simply individual enumerate in W.

    Similar discussion holds for L.

    Doubt 4 and 5 are referable clear

    4. Recentire that n = |N |, w = |W |, ` = |L|, and observe 3n + 2w + 2`. Demonstration that at
    start the prize is 3n and at the object at the object its 4

    5. Demonstration that the enumerate of comparisons needed to ascertain the utmost and the min-
    imum in the overcome fact (simply using comparisons) is at smallest d(3n − 4)/2e.