A sequence a = (a0, a1, a2, · · · , an) is said to be an almost p-ary sequence of period n + 1 if a0 = 0 and ai = ζbi p for 1 ≤ i ≤ n, where ζp is a primitive p-th root of unity and bi ∈ {0, 1, · · · , p − 1}. Such a sequence a is called perfect if all its out-of-phase autocorrelation coefficients are zero; and is called nearly perfect if its out-of-phase auto