next up previous contents
Next: Unstored Recursion Up: Program Design Previous: Base 3 Counter

Stored Tree

My next algorithm traversed a stored tree that contained all the possible orderings of the tasks at its leaves. Each node in the tree contained three sums of time taken on the three processors. The tree is built with a recursive function that adds the task it is currently on to three new nodes on the tree and calls itself three times for the nodes it has just made. The function stops when it has added the last task. Below is a visual description of the tree:

tex2html_wrap272

This is what a tree would look like containing all the orderings of 2 tasks. In the nodes there are some thing like iPj, that is the time for task i on processor j, you can see that the leaves of the tree contain all the possible orderings. Below is pseudo-code to build the tree and traverse it for the smallest ordering:

 buildtree(thisnode, taskon)

tex2html_wrap_inline230 (new node with taskon on processor 1)

tex2html_wrap_inline234 (new node with taskon on processor 2)

tex2html_wrap_inline238 (new node with taskon on processor 3)

tex2html_wrap_inline242

tex2html_wrap_inline244

tex2html_wrap_inline246

inc(taskon) do

if ( tex2html_wrap_inline250 )

buildtree(l, taskon)

buildtree(r, taskon)

buildtree(m, taskon)

 findleast(tasktree)

if (tasktree.l=NULL) do

if tasktree<lowest do

tex2html_wrap_inline264

else

findleast(tasktree.l)

findleast(tasktree.m)

findleast(tasktree.r)

With these two algorithms it is easy to build and search the tree for the smallest ordering. This algorithm has a problem in that it does not store the ordering that was the least, which will be solved in the next algorithm.



Jamie Marconi
Thu May 23 20:07:44 PDT 1996