Click to See Complete Forum and Search --> : Algorithm is fine but now implementation?


legend986
February 5th, 2008, 01:18 AM
As a matter of curiosity, we keep reading so many algorithms but if I'm not mistaken, it must be taking a lot of coding to actually get that to work. There is this job scheduling problem whose solution looks so simple - pick the one with the earliest finishing time. But are two arrays(linked lists) enough to implement that algorithm? What I thought of was to have one array with sorted order of starting times and the other with the sorted order of finishing times and then pick the least finishing time and then delete all incompatible jobs.

But at this stage, I thought I require a third linked list to hold the relations... i seem to be going up the ladder I guess... Is there a different way of achieving this?

CMPITG
February 10th, 2008, 12:00 PM
An example will be better for your problem cause I don't think I absolutely understand it.
BTW, have you tried to use a stack?

legend986
February 10th, 2008, 12:14 PM
Well I meant any job scheduling problem... Its like we have a couple of jobs with a start time and a finish time and we have to maximize some factor like having max number of jobs or running the jobs with the max priority. And no, I cannot see how a stack can be used... With a stack, isn't it like the Last in First Out? If thats the case, then only one factor can be addressed - completing the most recent job.

CMPITG
February 11th, 2008, 02:52 AM
Its like we have a couple of jobs with a start time and a finish time and we have to maximize some factor like having max number of jobs or running the jobs with the max priority
I think it depends on the factor you have mentioned.
There is this job scheduling problem whose solution looks so simple - pick the one with the earliest finishing time
Hope these help you:

http://riot.ieor.berkeley.edu/~vinhun/algorithms.html
http://www.ams.org/featurecolumn/archive/machines2.html
In the book Introduction to Algorithms, 2nd edition (MIT press), chapter 16, section 5: "A task-scheduling problem".