The algorithm is not general; it makes a number of assumptions. First, both the observed events and hidden events must be in a sequence. This sequence often corresponds to time. Second, these two sequences need to be aligned, and an observed event needs to correspond to exactly one hidden event. Third, computing the most likely hidden sequence up to a certain point t must only depend on the observed event at point t, and the most likely sequence at point t-1.
More technically, the Viterbi algorithm is a dynamic programming algorithm to find the hidden sequence of observations given an observed sequence of observations in a hidden Markov model. The resulting path is called the Viterbi path.
Recently, the terms "Viterbi path" and "Viterbi algorithm" have been applied to related dynamic programming algorithms, such as parsing, as well.