int getindexintosconst vector sa int tint ifsa return sa else return sa /true if [ <[ bool leqint int int int return | = & < /true if [ <[ bool leqint int int int int int return | = &leqa )bool suffix issmallerconst vector sconst vector const vector sa int int iint jint ifsa / vs can break tie after character return leqsi ] sa ]sj ] )else / vs can break tie after characters return leqsi ]si ] sa ]sj ]sj ] )figure supporting routines for merging the suffix arrays sa and sa figure sample - tree