trie insert( key, t, depth )
typekey key;
trie t;
int depth;
{
int j;
trie t1;
if ( t==NULL ) return( NewDataNode(key) );
if ( IsData(t) )
if (t->k == key)
Error /*** Key already in table ***/;
else { t1 = NewIntNode();
t1->p[ charac(depth,t->k) ] = t;
t = insert( key, t1, depth );
}
else { j = charac(depth,key);
t->p[j] = insert( key, t->p[j], depth+1 );
}
return( t );
}
|