Q4 10 Suppose you are a cable guy and are sent out for jobs to complete in a single day. Given job j; each has a start time s; and finish time f;. Your goal is to complete the most number of jobs assigned. The only requirement is you are allowed to start a job late by y minutes, (there is no travel time between jobs). Otherwise, there is no allowed overlap. So I can have a job that goes 1pm-1:37pm and start another one that goes from 1:30pm to 2:30pm PART A Create and analyze code for a greedy algorithm that follows the greedy strategy of choosing the job that starts the latest compatible to currently selected jobs. (HINT you can order jobs in order of decreasing start time) Part B Prove that the greedy strategy of choosing the job that starts the latest is possible in an optimal solution. (Greedy choice property)

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter5: Control Structures Ii (repetition)
Section: Chapter Questions
Problem 20PE: When you borrow money to buy a house, a car, or for some other purpose, you repay the loan by making...
icon
Related questions
Question

Please solve the following greedy algorithms problem: (show all work and solve asap)

given: y = 9 

Q4
10
Suppose you are a cable guy and are sent out for jobs to complete in a single day. Given
job j; each has a start time s; and finish time f;. Your goal is to complete the most
number of jobs assigned. The only requirement is you are allowed to start a job late by y
minutes, (there is no travel time between jobs). Otherwise, there is no allowed overlap. So
I can have a job that goes 1pm-1:37pm and start another one that goes from 1:30pm to
2:30pm
PART A
Create and analyze code for a greedy algorithm that follows the greedy strategy of
choosing the job that starts the latest compatible to currently selected jobs. (HINT you
can order jobs in order of decreasing start time)
Part B
Prove that the greedy strategy of choosing the job that starts the latest is possible in an
optimal solution. (Greedy choice property)
Transcribed Image Text:Q4 10 Suppose you are a cable guy and are sent out for jobs to complete in a single day. Given job j; each has a start time s; and finish time f;. Your goal is to complete the most number of jobs assigned. The only requirement is you are allowed to start a job late by y minutes, (there is no travel time between jobs). Otherwise, there is no allowed overlap. So I can have a job that goes 1pm-1:37pm and start another one that goes from 1:30pm to 2:30pm PART A Create and analyze code for a greedy algorithm that follows the greedy strategy of choosing the job that starts the latest compatible to currently selected jobs. (HINT you can order jobs in order of decreasing start time) Part B Prove that the greedy strategy of choosing the job that starts the latest is possible in an optimal solution. (Greedy choice property)
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning