-4

what is Greedy solution for scheduling problem when running time (like 5 minutes, 10 minutes, not starting and ending time ) of problem is given and you have m process to run them then what is minimum of maximum time ?
Assume i have nine jobs ( 3,5,6,10,11,14,15,18,20 minutes) and three process then solution is

1st process handle --> 20 + 14

2nd process handle --> 18 + 11 +5

3rd process handle --> 15 + 10 + 6 + 3

minmimum time is 34 minutes

shark_s
  • 31
  • 5
  • It seems like you just posted an edit which contains the answer to your own question. Can you clarify what you're asking? – nhouser9 Apr 23 '16 at 06:45
  • I want a greedy algorithm for it for sove such type of problems . – shark_s Apr 23 '16 at 06:48
  • While tasks remain, add the longest task to the process that currently has the shortest running time. – user3386109 Apr 23 '16 at 06:48
  • it is not working you can see in above explanation. – shark_s Apr 23 '16 at 06:51
  • Greedy algorithms are not optimal, they are just easy to implement, and have short execution times. So the answer is 35, instead of 34. That's the price you pay for being greedy. – user3386109 Apr 23 '16 at 06:55
  • I doubt that there exists a greedy algorithm that solves this problem exactly. – Henry Apr 23 '16 at 06:55
  • So there is any algorithm except exponential complexity to solve this type problem? – shark_s Apr 23 '16 at 06:57
  • That's an entirely different question. So you might to start a new question titled: *"Is there a polynomial time solution to the basic version of the job shop problem?"* Reference: [job shop problem](https://en.wikipedia.org/wiki/Job_shop_scheduling). – user3386109 Apr 23 '16 at 07:09
  • What are you looking for? A greedy algorithm that is always resulting in lowest overall time, and one for maximum time? (And must all processing units be busy at any time?) – rpy Apr 23 '16 at 07:12
  • i am looking for an algorithm which gives minimum of maximum time taken by a process. – shark_s Apr 23 '16 at 07:16

2 Answers2

0

Given that the problem is NP-hard (see for example here), it is unlikely that a polynomial time algorithm exists that gives an exact solution in all cases.

Henry
  • 42,982
  • 7
  • 68
  • 84
0

First of all, see the Wikipedia page: https://en.wikipedia.org/wiki/Greedy_algorithm

From the first section of the article:

A greedy algorithm is an algorithm that follows the problem solving heuristic of making the locally optimal choice at each stage with the hope of finding a global optimum. In many problems, a greedy strategy does not in general produce an optimal solution...

There are 2 important points to highlight here:

  1. A greedy algorithm in not necessarily going to find an optimal solution.

  2. There are often many different greedy approaches for a single problem.

Using your problem as an example, both of these approaches are greedy:

Greedy Approach #1: As each process becomes available, assign the longest task to the process. This could give the following results:

Process 1: 20 + 10 + 3 = 33

Process 2: 18 + 11 + 6 = 35

Process 3: 15 + 14 + 5 = 34

Total time: 35

Greedy Approach #2: As each process becomes available, assign the shortest task to the process. This would give the following results:

Process 1: 3 + 10 + 15 = 28

Process 2: 5 + 11 + 18 = 34

Process 3: 6 + 14 + 20 = 40

Total time: 40

Both these approaches are greedy algorithms. The one big assumption here is that the problem is simply to process all the tasks. If the problem is to process all the tasks in the shortest time possible, then (as has been stated already in the comments) there is no greedy algorithm that can solve this problem.

Community
  • 1
  • 1