Name: Anonymous 2016-08-19 12:32
challenges tba by challengers!
1 on 1 battles!
1 on 1 battles!
Node Fields : .Id | .Dir | .Val | .LeftId | .RightId | .AboveId
function RoteDir(dir)
case dir == above: dir = left
case dir == left: dir = right
case dir == right: dir = above
return dir
function getNodeVal(Val, Nodelist, rootId){
10 REM TREE is an adjacency matrix describing a tree
20 REM NNODES is the number of nodes in the tree
25 REM For this task, the program must traverse the nodes
26 REM so the adjacency matrix is irrelevant
30 FOR I=1 TO NNODES
40 PRINT "FOUND NODE ";I
50 NEXT I
60 PRINT "WHAT ACCEPTABLE LISP IS THIS?"
void traverse(Node *e, void (*pre)(Node*,void*), void *prectx,
void (*post)(Node*,void*), void *postctx) {
Node *i = e;
goto child:
while(e->firstchild) {
e = e->firstchild;
child:
pre(e, prectx);
}
for(;;) {
post(e, postctx);
if(e->nextsib) {
e = e->nextsib;
goto childloop;
}
if(e == i || !e->parent)
return;
e = e->parent;
}
}
goto
instead?traverse: ; ecx:prectx edx:postctx ebx:e esi:pre edi:post
mov ebp, ebx
loop1:
mov eax, ebx
call esi
mov ebx, [eax+Node.firstchild]
test ebx, ebx
jnz loop1
loop2:
call edi
mov ebx, [eax+Node.nextsib]
test ebx, ebx
jnz loop1
cmp eax, ebp
jz traverse_ret
mov eax, [eax+Node.parent]
test eax, eax
jnz loop2
traverse_ret:
ret