[Home]
[Chapter]
[Contents]
[Previous Algorithm]
[Next Algorithm]


Binary tree insertion


procedure insert( key : typekey; var t : tree ); begin if t = nil then t := NewNode( key, nil, nil ) else if t^.k = key then Error {*** Key already in table ***} else if t^.k < key then insert( key, t^.right ) else insert( key, t^.left ) end;

C source (3411.ins.c) Pascal source (3411.ins.p)



© Addison-Wesley Publishing Co. Inc.