List pending task

Several students want to get into sections for the class, some of them are already registered for one section, but want to change the section, so they all fall into waiting lists. A student can get into a new section only if someone leaves this section. No student will want to abandon the section in which they are already located, unless this necessarily falls into the section that they are waiting for. The waiting list for each section will first be the first.

Get as many students as possible in the right sections.

This issue can quickly jump to a deadlock scenario. My question is: are there any known solutions to this problem?


One trivial solution would be to take each section one at a time and force the first student from the waiting list into the section, and then check if someone will stop when everything is allowed (O (n) or more sections). This will work in some cases, but I think there may be better options, including forcing more than one student to a section (O (n) or more on a student’s account) and / or working in more than one section at a time (O (bad ): -)

+5
source share
3 answers

, ? - , node , , , , . , .

+2

, . 8 (1..8) 4 . , 2 . , .

, ( ).

+------+-----+-----+-----+
| stud | now | req | que |
+------+-----+-----+-----+
|    1 |   A |   D |   2 |
|    2 |   A |   D |   1 |
|    3 |   B |   B |   - |
|    4 |   B |   A |   2 |
|    5 |   C |   A |   1 |
|    6 |   C |   C |   - |
|    7 |   D |   C |   1 |
|    8 |   D |   B |   1 |
+------+-----+-----+-----+

:

+-----+           +-----+           +-----+
|  C  |---[5]--->1|  A  |2<---[4]---|  B  |
+-----+           +-----+           +-----+
   1               |   |               1
   ^               |   |               ^
   |              [1] [2]              |
   |               |   |               |
  [7]              |   |              [8]
   |               V   V               |
   |               2   1               |
   |              +-----+              |
   \--------------|  D  |--------------/
                  +-----+

, . , . . A , . , 5 A, C, 7. D, 2. A. , A , .

A, A . . , .

:

+-----+           +-----+           +-----+
|  C  |           |  A  |1<---[4]---|  B  |
+-----+           +-----+           +-----+
                   |                   1
                   |                   ^
                  [1]                  |
                   |                   |
                   |                  [8]
                   V                   |
                   1                   |
                  +-----+              |
                  |  D  |--------------/
                  +-----+

, .

, , . , , .

, - , , .

+2

. . , . , , , "" , "" , , , .

+1

All Articles