{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

key5sp01 - COP3530C.01 Spring 2001 S Lang Solution Key to...

Info icon This preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
COP3530C.01, Spring 2001 S. Lang Solution Key to Assignment #5 (40 pts.) March 29, 2001 1. (10 pts.) Exercise 10.3. (The binary merge tree is drawn sideways, so that the “left” branch is above the “right” branch in the following figure.) 2. (10 pts) Exercise 10.2, Part (a). A greedy strategy that maximizes the total earning (in dollars) selects the job with the highest earning first, with the second highest earning next, etc, if the jobs can be completed by their respective deadlines. More precisely, the following is the algorithm: (1) Sort the jobs based their earnings from high to low, breaking ties with the deadlines by placing smaller (earlier) deadlines at the front. After sorting, we assume array d [1.. n ] contains the earnings (in dollars) of the jobs 1 through n , and array t [1.. n ] contains the deadlines for the corresponding jobs. (Thus, job 1 earns d [1] dollars if completed by time t [1], etc.) Note that we may assume each deadline value is n because each job takes one time unit to complete, so n jobs cannot take more than n time units. Therefore, we may replace any value in array d [1.. n ] which is larger than n by value n . (2) Find the maximum deadline in array t [1.. n ], call it max. Create an array p [1..max] and initialize to zero values. The purpose of the p array is to record when the jobs are scheduled
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern