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

Info iconThis 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 in the time slots; thus, if p [ k ] = j > 0, job j is being completed in time slot k . (3)
Background image of page 1

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

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

This document was uploaded on 06/13/2011.

Page1 / 3

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

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online