View/Edit #67:add_tree_to_heap

Switch to edit mode.

Name(s): add_tree_to_heap
1:  {heap, tree, degree} = args
2:  if (tree == {})
3:    return heap
4:  elseif (length(heap) < degree)
5:    while (length(heap) < degree - 1)
6:      heap = {@heap, {}}
7:    endwhile
8:    return {@heap, tree}
9:  elseif (!heap[degree])
10:   heap[degree] = tree
11:   return heap
12: else
13:   existing_tree = heap[degree]
14:   heap[degree] = {}
15:   return this:add_tree_to_heap(heap, this:tree_join(tree, existing_tree), degree + 1)
16: endif

Verb arguments: this none this
Verb perms: Readable eXecutable NOT-Debug
Verb owned by: Hacker (#60)

You are not logged in.

[home | help | who | search | setup | code]