phrase = first phrase in input array loop binary search for phrase in word[0..nword-1] for all phrases equal in the first k words select one at random, pointed to by p phrase = word following p if k-th word of phrase is length 0 break print k-th word of phrase
Example 1: Pseudocode for generating nonsense text.