Question

There is a very simple greedy algorithm(Pseudocode) that maximizes your total reward. Find it. Consider the...

There is a very simple greedy algorithm(Pseudocode) that maximizes your total reward. Find it.

Consider the following scheduling problem. Each task I has a length L[I] and a deadline D[I].

There is a single processor that handles one task at a time. Let E[I] be the ending time of I under a given schedule.

You get paid an amount D[I] − E[I] if you finish task I early and you get fined an amount E[I] − D[I] if you finish task I late.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Greedy Approach:

Sort all tasks in ascending order of their length

consider an array of tasks Tasks[I] sort it

for(task t : allTasks)

{

process smallest length task

calculate profit

smallest length task will be farthest from the deadline and will earn more profit

}

since we kept picking task which gives more profit initially(irrespective of final result) this approach is greedy.

Add a comment
Know the answer?
Add Answer to:
There is a very simple greedy algorithm(Pseudocode) that maximizes your total reward. Find it. Consider the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 16. Consider a single-processor system that uses the round-robin (RR) process scheduling algorithm. Assume that the...

    16. Consider a single-processor system that uses the round-robin (RR) process scheduling algorithm. Assume that the time quantum is 10 milliseconds. Consider the five processes with the arrival time and the burst time, in milliseconds, shown in the table below Arrival Time Burst Time (milliseconds) (milliseconds) Process Pl P2 P3 P4 P5 0 24 20 23 24 Which of the five processes is the last to finish its execution? (A) P (B) P2 (C) P3 (D) P4 (E) P5

  • Need in pseudocode Program 2: POWIN3D. In the early 80s, hackers used to write in an...

    Need in pseudocode Program 2: POWIN3D. In the early 80s, hackers used to write in an obfuscated, but mostly readable way called "leet" - short for "elite". In essence, it was a simple character replacement algorithm, whereya single "regular" character was replaced by one or more "leet" characters; numbers remained the same. Here's one of the most readable versions: g9m AS$y 00u | |р | P v II 9 IQ W LrRXI>< VI Note! You will need to know how...

  • Please help me with this answer. Performance Comparison for Dijkstra Algorithm and Bellman-Ford Algorithm Problem Description...

    Please help me with this answer. Performance Comparison for Dijkstra Algorithm and Bellman-Ford Algorithm Problem Description The shortest path problem is one of most important problems in graph theory and computer science in general. Shortest path problem is one of typical optimization problems. Given a graph G = (V,E), the goal is to nd a minimum cost path from s → t, s,t ∈ V . This variant is called one-to-one shortest path problem. Other variants are one-to-all (compute shortest...

  • For this assignment, your job is to create a simple game called Opoly. The objectives of...

    For this assignment, your job is to create a simple game called Opoly. The objectives of this assignment are to: Break down a problem into smaller, easier problems. Write Java methods that call upon other methods to accomplish tasks. Use a seed value to generate random a sequence of random numbers. Learn the coding practice of writing methods that perform a specific task. Opoly works this way: The board is a circular track of variable length (the user determines the...

  • This is java and make simple program. CPSC 1100. Thanks CSPS 1100 Lab 4 ay total...

    This is java and make simple program. CPSC 1100. Thanks CSPS 1100 Lab 4 ay total Also I would need a new name for the daubles. An example here might be double tRtalD-caradd xD, YD) 1. (a) We are going to begin with some simple math, reading input, and formatted output. Create a class called MuCalsustec Yau will not have an instance variable. Since you have no instance variables to initialize, you do nat need a constructar. Do NOT create...

  • C++ HW Question Your program will simulate a simple change maker for a vending machine. It...

    C++ HW Question Your program will simulate a simple change maker for a vending machine. It will start with a stock of coins and dollars. It will then repeatedly request the price for an item to be purchased or to quit. If given a price, it will accept nickels, dimes, quarters, one-dollar and five-dollar bills—deposited one at a time—in payment. When the user has deposited enough to cover the cost of the item, the program will calculate the coins to...

  • Build a bank simulator system using the C++ STL queue library. You are required to create your ow...

    build a bank simulator system using the C++ STL queue library. You are required to create your own ADT for that system that: First, Read from a file the data of incoming customers which includes ArrivalID, StartTime, and ProcessTime. You have one line in your Bank in which you will serve your customers as per to their arrival time. For example if you read the following data from the file A 1 5 B 2 5 C 4 5 D...

  • Build a bank simulator system using the C++ STL queue library. You are required to create your ow...

    build a bank simulator system using the C++ STL queue library. You are required to create your own ADT for that system that: First, Read from a file the data of incoming customers which includes ArrivalID, StartTime, and ProcessTime. You have one line in your Bank in which you will serve your customers as per to their arrival time. For example if you read the following data from the file A 1 5 B 2 5 C 4 5 D...

  • Consider the proposal. Should SCF accept or reject ACL’s request? If you were the project manager,...

    Consider the proposal. Should SCF accept or reject ACL’s request? If you were the project manager, which option would you select? What risks are involved with your choice and with ACL’s request? Shell Case Fabricators BACKGROUND Shell Case Fabricators (SCF) designs and builds shell casings that enclose electronic products such as calculators, cell phones, modems. Typically the cases are plastic or plastic compounds. SCF has six different production lines that cover different types of product. For example, the largest high...

  • You will be writing a simple Java program that implements an ancient form of encryption known...

    You will be writing a simple Java program that implements an ancient form of encryption known as a substitution cipher or a Caesar cipher (after Julius Caesar, who reportedly used it to send messages to his armies) or a shift cipher. In a Caesar cipher, the letters in a message are replaced by the letters of a "shifted" alphabet. So for example if we had a shift of 3 we might have the following replacements: Original alphabet: A B C...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT