P-distinct strings
Input:
length n
Output:
The set of p-distinct strings of length n on alphabet Σ={σ1,...,σn}


T
r
y

i
t


n

pdistinct←{ε}
k←1
while k ≤ n do
next←∅
for all w in pdistinct do
c←1
while c ≤ card(alphabet(w)) + 1 do
next←next ∪ {w.σc}
c←c + 1
pdistinct←next
k←k + 1
return pdistinct
Reference
Bill Smyth
Computing patterns in strings
ACM Press Books, Pearson Education, 423 pages, ISBN 0201398397, 2003

Valid XHTML 1.0 Strict CSS Valide !