index substring being represented ana anana banana na nana figure suffix array that stores only indices (full substrings shown for referencewe can also use the suffix array to find the number of occurrences of pthey will be stored sequentially in the suffix arraythus two binary searches suffice to find range of suffixes that will be guaranteed to begin with one way to speed this search is to compute the longest common prefix (lcpfor each consecutive pair of substringsif this computation is done as the suffix array is builtthen each query to find the number of occurrences of can be sped up to op log although this is not obvious figure shows the lcp computed for each substringrelative to the preceding substring the longest common prefix also provides information about the longest pattern that occurs twice in the textlook for the largest lcp valueand take that many characters of the corresponding substring in figure this is and the longest repeated pattern is ana figure shows simple code to compute the suffix array and longest common prefix information for any string line obtains primitive (char *string from strand lines to obtain the suffixes by computing and storing these pointers using pointer arithmetic (line at lines and the suffixes are sortedthe code at line represents the ++ lambda featurein which the "less thanfunction that is needed for two char types is provided as the third parameter to sortwithout the need to write named function lines and compute the suffixesstarting indices using pointer arithmeticand lines to compute the longest common prefixes for adjacent entries by calling the computelcp routine written at lines to index lcp substring being represented ana anana banana na nana figure suffix array for "banana"includes longest common prefix (lcp