GATE CSE
First time here? Checkout the FAQ!
x
0 votes
1.5k views

What is the time complexity of job sequencing with deadline using greedy algorithm?

  • O(n)
  • O(log n)
  • O(n log n)
  • O(n2)

Made Easy

Full Syllabus Test-6 : Basic Level : Practice Test-14

Q 19

Please give reference for this answer to this algorithm.

asked in Algorithms by Veteran (41.4k points)   | 1.5k views

@Anurag Pandey ,

It seems like you have virtually answered the question :) It should be O(N) as per this lecture notes. Let me read it through. Thanks for reference. (You should add answer , if you are sure it is correct, & I think it will be mostly as it is MIT !)

Though do we need to sort ? Before O(N) algorithm stated there ? In that case, wont this come down to O(NlogN). I'm yet reading it , so now I've not realized, whether it does sorting even in Fast algorithm !
I read it superficially, I guess we need sorting to resolve sequencing conflicts among the jobs that have same deadlines.

2 Answers

0 votes

1. sort job according to decresing order of deadline =  O(nlogn)

2.for each job find slot in array of size n = O(n^2)

 

total time  = O(nlogn) + O(n^2) =O(n^2)

answered by Active (2k points)  
Can you give me reference to this algorithm ? (Actually I know the formal procedure, just want to be sure N^2 is correct lower bound !

Also the always asked question in case algorithm, can we do better ? (In case of greedy or using other methods ? :) )
0 votes

1) To sort N Job - O(nlogn).

2)  Take each job and start where the deadline is given ans keep searching for the vaccant location. So if there are N jobs for each job we need to search N slots. i.e O(n^2)

so total time complexity is O(n^2)

http://www.geeksforgeeks.org/job-sequencing-problem-set-1-greedy-algorithm/

answered by Loyal (3.9k points)  

Related questions

+1 vote
3 answers
1
asked in Algorithms by bahirNaik Loyal (3.6k points)   | 108 views
0 votes
0 answers
3
asked in Algorithms by Tushar Shinde Loyal (2.6k points)   | 293 views


Top Users May 2017
  1. akash.dinkar12

    3338 Points

  2. pawan kumarln

    2108 Points

  3. Bikram

    1922 Points

  4. sh!va

    1682 Points

  5. Arjun

    1614 Points

  6. Devshree Dubey

    1272 Points

  7. Debashish Deka

    1208 Points

  8. Angkit

    1056 Points

  9. LeenSharma

    1018 Points

  10. Arnab Bhadra

    812 Points

Monthly Topper: Rs. 500 gift card
Top Users 2017 May 22 - 28
  1. Bikram

    1008 Points

  2. pawan kumarln

    734 Points

  3. Arnab Bhadra

    726 Points

  4. Arjun

    342 Points

  5. bharti

    328 Points


22,893 questions
29,196 answers
65,302 comments
27,695 users