LZ78 algorithms achieve compression by replacing repeated occurrences of data with references to a dictionary that is built based on the input data stream. Each dictionary entry is of the form codice_1, where "index" is the index to a previous dictionary entry, and character is appended to the string represented by . For example, "abc" would be stored (in reverse order) as follows: codice_2, where an index of 0 specifies the first character of a string. The algorithm initializes "last matching index" = 0 and "next available index" = 1. For each character of the input stream, the dictionary is searched for a match: {last matching index, character}. If a match is found, then "last matching index" is set to the index of the matching entry, and nothing is output. If a match is not found, then a new dictionary entry is created: dictionary[next available index = {last matching index, character}, and the algorithm outputs "last matching index", followed by "character", then resets "last matching index" = 0 and increments "next available index". Once the dictionary is full, no more entries are added. When the end of the input stream is reached, the algorithm outputs "last matching index". Note that strings are stored in the dictionary in reverse order, which an LZ78 decoder will have to deal with.