This algorithm calculates the cost for every possible combination
of the tasks by fact that a combination can be represented as a base 3 number.
For an n digit number there are different digit arrangements or
combinations. The Base 3 Counter algorithm counts from 0 to
where n
is the number of tasks to order. For each count the number is converted to
base 3 and the time cost of running for that order is calculated from the table
of costs. If the calculated cost is less than the current lowest cost then
the current number and its cost are stored as the new lowest. Below is a short
pseudo-code of the algorithm:
forto
do
calccost(i)
if time < lowest then
![]()
![]()
calccost(i)
tobase3(i)
for
downto 0 do
![]()
max(time)
The calccost function uses a two dimensional array taskweight that contains the time taken by each task on each processor. time is an array [0..2] that the intermediate sum of time on each processor is stored for use in max. max is a simple function that returns the largest of the three values sent to it which is the running time of ith ordering. The number lowestset stores which ith ordering is the smallest so far, and can be used to show what ordering was obtained as smallest.