Software Design
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreSoftware Design

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 2nd, 2007, 02:46 PM
nz86 nz86 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2007
Posts: 2 nz86 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 43 sec
Reputation Power: 0
Help on a proof for my greedy algorithm

Hi, I was wondering if anyone could help me prove my algorithm for the problem below.

My greedy algorithm looks for the most conflicts:

R = set of all intervals
A = empty set
while R is not empty
choose i in R s.t. it has the most conflicts
Add i to A
Remove i and all other intervals it has conflicts with from R
End while
Return A

I'm pretty sure this algorithm works, I just can't get my proof for it exactly right. If anyone can help, that'd be great!

The following problem is below:

The manager of a large student union on campus comes to you with the following
problem. She’s in charge of a group of students, each of whom is scheduled to work one
shift during the week. There are different jobs associated with these shifts , but we can
view each shift as a single contiguous interval of time. There can be multiple shifts going
on at once. The manager is trying to find a subset of these students to form a supervising
committee that she can meet with once a week. She considers such a committee to be
complete if, for every student not on the committee, the student shift overlaps (at least
partially) the shift of some student who is on the committee. In this way, each student’s
performance can be observed by at least one person who is serving on the committee.
Give an efficient algorithm that takes the schedule of n shifts and produces a
complete supervising committee containing as few students as possible.

Reply With Quote
  #2  
Old August 9th, 2007, 12:42 PM
Michael88 Michael88 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Posts: 57 Michael88 User rank is Sergeant (500 - 2000 Reputation Level)Michael88 User rank is Sergeant (500 - 2000 Reputation Level)Michael88 User rank is Sergeant (500 - 2000 Reputation Level)Michael88 User rank is Sergeant (500 - 2000 Reputation Level)Michael88 User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 4 Days 28 m 14 sec
Reputation Power: 16
you can't be sure about its correctness if don't prove it. Actually your algorithm is not correct, this can be seen on this simple test-case:

Code:
1.----------(2)
2.                       -------(2)
3.      --------------------(3)
4.                        -------------------- (4)
5.                                         --------------------(3)
6.                                         ----------(2)
7.                                                               ---------(1)


number 4 has 4 conflicts, but if we choose it, the we'll have to choose number 1 and number 7 too. So we would rather choose number 3 and number 5.

This problem does require a greedy algorithm. You should not count conflicts, but you have to sort the intervals with respect to their left or right ends and process them step by step. I will write the exact algorithm if you wish.

Last edited by Michael88 : August 9th, 2007 at 12:45 PM.

Reply With Quote
  #3  
Old August 9th, 2007, 12:52 PM
nz86 nz86 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2007
Posts: 2 nz86 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 43 sec
Reputation Power: 0
I figured it out a few days ago. Thanks for reply though!

Reply With Quote
  #4  
Old February 1st, 2012, 10:44 AM
souliloquy souliloquy is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2012
Posts: 1 souliloquy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 m 33 sec
Reputation Power: 0
Could someone help me out with this? I'm still having trouble after sorting the set of student shifts by the earliest start time or the earliest finish time. Each greedy criteria seems to fail on one or more test cases that I have.

Any hints would be greatly appreciated.

Thanks.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreSoftware Design > Help on a proof for my greedy algorithm

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap