Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: THEend8_
Practical Informatics II SOSE 2022
On this exercise list, the implementation of Task 1 is completed by the last person listed in the
phone book. The other man is taking a test. The remaining tasks will be evaluated together.
Task 1 Graffiti Post Processor (70%)
At present, the tutorial selection in PI-2 follows the principle of "first come, first served".
Alternatively, we can doodle the dates, each student ticks the dates on which they have time, and
then we assign the students to the tutorial according to their choice. We will implement the
method of determining this distribution in this exercise sheet.
The method takes two parameters:
1.Election results. For privacy reasons, the name is omitted here, so it is a two-dimensional
array with each row containing the yes/no decision of the student for each tutorial.
2.The ability of tutorials. Since it doesn't have any effect on the algorithms below, we want to
be a little more flexible at this point and allow each tutorial to have a different capacity. The
capacity in the array is the same as the appointment order in the graffiti. The way to do this
is to adjust the entries in the array so that they reflect the remaining capacity after allocation.
The method to implement should return an array containing the number of tutorials assigned to it
by each student. The tutorial number begins with 0, so it is also an index of tutorial capacity and
2. Dimensions of election results.
The distribution algorithm consists of two nested loops and works as follows:
1.For all students, they must save their current assignment to the tutorial. At the beginning,
they are not associated with any tutorials.
2.The outer ring passes through all students in turn. After they are finished, students must be
returned to the assignment of tutorials.
3.Inner Ring is looking for a suitable tutorial for current students. To do this, your tutorial
number will be increased until the tutorial you selected is found and there is still room. If it
has not been assigned to any tutorials before, the search starts with tutorial 0. At the end of
the loop, there are two situations: Either a suitable tutorial is found, and then its available
capacity must be adjusted, because the student now has a place in this tutorial, and the
external loop will continue with the next student. Or if you can't find a suitable tutorial, your
tutorial selection will be set to Unassigned again
PI 2, Sose 2022
2
And the external loop continues (backtracking) among the previous students. Note that
"Continue" means that the previous student in the current tutorial must quit again because
she will look for a new one in the next loop. If there are no previous students, because the
current student is already the first student, the distribution is not possible, and the method
returns NULL as the result.