trees the second character of the four-letter word groupwith new mapand then the third characterand finally the fourth character the general outline is for each group gcontaining words of length len for each position (ranging from to len- make an empty maprepstowords for each word obtain ' representative by removing position update repstowords use cliques in repstowords to update adjwords map figure contains an implementation of this algorithm the running time improves to two seconds it is interesting to note that although the use of the additional maps makes the algorithm fasterand the syntax is relatively cleanthe code makes no use of the fact that the keys of the map are maintained in sorted order /computes map in which the keys are words and values are vectors of words /that differ in only one character from the corresponding key /uses an efficient algorithm that is ( log nwith map mapcomputeadjacentwordsconst vector words mapadjwordsmapwordsbylength/group the words by their length forauto str words wordsbylengthstr lengthpush_backstr )/work on each group separately forauto entry wordsbylength const vector groupswords entry secondint groupnum entry first/work on each position in each group forint groupnum++ figure function to compute map containing words as keys and vector of words that differ in only one character as values this version runs in seconds on an , word dictionary