Consider a queue of \(\textbf{JOB}\)s having each an identifier (integer) and a priority between 0 and \(\texttt{N-1}\) (\(\texttt{N}\) constant).
We want to transform the queue so that tasks of priority 0 are in the front, followed by tasks of priority 1 ... finally, tasks of priority \(\texttt{N-1}\) are at the end of the queue. Tasks of same priority must be stored in reverse order of their arrival.

  • Give the adequate declarations in a header file.
  • Write a function that converts such a queue so it can verify the above property. Use exclusively the operations of the ADT given in lectures.
  • Write a \texttt{main} function to test your program.

Difficulty level
This exercise is mostly suitable for students
Send me your solution and get featured here !!

Back to the list of exercises
Looking for a more challenging exercise, try this one !!
Implementation of a deque