![]() |
.. (לתיקייה המכילה) | |
Are the running times specified in the exercise worst-case or average-case?
| Worst. |
What do we do in case of a memory allocation error?
|
Print an error message to stderr and exit the program. |
What exactly does "quit()" do? Specifically, does it terminate the program (using exit()) ?
| The function should release the resources you allocated to the program. You can assume that quit() will be the last function to be called. Therefore it is not necessary to perform an exit() from it. |
Can the dry part of the exercise be written in english?
| Yes. |
What should I do if the user tries to enter an illegal priority (e.g. greater than k)?
|
Print an error message to stderr and do not include the job. In other words, apart from the error message, the insert command is ignored. |
What should I do if I get an insert command with the id of a job that already exists?
| The old job will be overwritten. |
How should my program handle an illegal init(k) command, for example with k negative or zero?
| Print an error message to stderr and abort the program. |
The return values of print_job(), oldest_job() and first_job() are of type int, while id's are unsigned ints. Doesn't this cause problems?
|
Before you assign the return value of one of these functions to an unsigned int variable you have to check that it's not -1. If it isn't then during assignment a cast will be (automatically) performed. Potentially there could be a problem with id's that are very large unsigned int's (larger than the largest possible int). You can assume this does not happen. |
What exactly does oldest_job() return?
| The id of the job that was entered first in time (the oldest) of all currently existing jobs. |
Can we implement quit() in O(n+k) instead of O(n)?
| No. To get full points for quit() it must be O(n). |
What should delete_job do if it is the user tries to delete a non-existant job?
|
Nothing. No need to print an error message. |

