I am struggling with the Pseudo code for an that algorithm assigns "least filled slot first" to a tasks on multi-core chip.
So far I have written following:
What I do not like here is:
- In while loop I am removing one by one elements of $R$ (which is a row vector with $m$ elements). This means the complexity of $m^2$, however I could have sorted $R$ outside the loop and then just removed the head every time that would reduce the complexity to $m\log m + m$ for this part. But in that case the index $j$ will get jumbled up and not usable in the rest of the part. Is there an elegant Pseudo-code way of saying "store the indices before sorting for later use"?
- Any other stylistic suggestions that make it easier to read while still reducing the "implementation complexity" ?
In general, I know its a trade-off between readability vs complexity. Generally, the main purpose of presenting an algorithm is to make it readable and leave the implementation details to the implementer. But just to be pedantic ..