word is considered as any sequence of letters and digits starting with letter since words may be of widely different lengthsthe actual characters are stored in an array bufferand the tree nodes contain the index of the key' first character it is desirable that the line numbers be printed in ascending order in the cross-reference index thereforethe item lists must be generated in the same order as they are scanned upon printing this requirement suggests the use of two pointers in each word nodeone referring to the firstand one referring to the last item on the list we assume the existence of global writer wand variable representing the current line number in the text const wordlen (adens _crossref *type word array wordlen of charitem pointer to recordlnointegernextitem endnode pointer to record keywordfirstlastitem(*list*leftrightnode (*tree*endvar lineintegerprocedure search (var wnodevar aword)var qitembegin if nil then (*word not in treenew entryinsert*new( )new( ) lno :linecopy(aw key) first :qw last :qw left :nilw right :nil elsif key then search( rightaelsif key then search( leftaelse (*old entry*new( ) lno :linew last next :qw last : end end searchprocedure tabulate (wnode)var mintegeritemitembegin if nil then tabulate( left)texts writestring(ww key)texts write(wtab)item : firstm : repeat if then texts writeln( )texts write(wtab) : endinc( )texts writeint(witem lno )item :item next until item niltexts writeln( )tabulate( rightend end tabulateprocedure crossref (var rtexts reader)var rootnode(*uses global writer *