All pastes #636172 Raw Edit

Unnamed

public text v1 · immutable
#636172 ·published 2007-07-27 18:05 UTC
rendered paste body
void inorderIter(node *root)
{
    node *stk[100];
    int top=-1;
    stk[++top]=root;
    int mark[100];
    memset(mark,0,sizeof(mark));
    while(top>=0)
    {
        node *t=stk[top];
        if(mark[top]==0)
        {
            mark[top]=1;
            if(t->left)
                stk[++top]=t->left;
            continue;
        }
        if(mark[top]==1)
        {
            printf("%d ",t->data);
            mark[top]=0;
            top--;
            if(t->right)
                stk[++top]=t->right;
        }                 
    }
}