View the step-by-step solution to:

Question

4.     The following pseudocode represents an algorithm to find the median value in a list

containing N unique numbers. In this algorithm, we assume that FindLargest is a primitive to us, so we can directly call it in the algorithm. Please fill up the blanks to make it work appropriately.



Step 1:  Get the values L1L2, . . ., LN of the numbers in the list

Step 2:  If N is even then 

Let M = N / 2

              Else 

Let = (N + 1) / 2

Step 3:  While (______ ) do steps 4 through 9 

Step 4:             Use FindLargest to find the location of the largest number

                         in the list L1, L2, . . ., LN

Step 5:             Exchange Llocation and LN as follows

Step 6:             Temp = ____  

Step 7:             LN = _____

Step 8:             Llocation = _____

Step 9:             Set to _____   and effectively shorten the list

Step 10:  Print the message 'The median is: '

Step 11:  Print the value of LM

Step 12:  Stop

Top Answer

Answer is given... View the full answer

Sign up to view the full answer

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question