ç¶ã»BlockSorting(BWT)
BlockSorting - 西尾泰åã®ã¯ã¦ãªãã¤ã¢ãªã¼ http://d.hatena.ne.jp/nishiohirokazu/20080218/1203322931
ã¡ããã¨èªãã ãããã£ããããããã«nçªç®ã®"X"ã¯nçªç®ã®"X"ã«ã¤ãªããã¨è¨ããã¨ããã©ããã£ããã¨ã¬ã¬ã³ãã«æ¸ããããªâ¦ã
ããªãã«åæåã«é£çªããµã£ããç´ ç´ã«æ¸ããã
# 復å from collections import defaultdict count = defaultdict(int) def inc(c): count[c] += 1 return count[c] tails = [(c, inc(c)) for c in tails] heads = list(sorted(tails)) cur = start result = [] print start # => 1 print tails # => [('b', 1), ('a', 1), ('b', 2), ('a', 2)] print heads # => [('a', 1), ('a', 2), ('b', 1), ('b', 2)] for i in range(len(tails)): pair = heads[cur] result.append(pair[0]) cur = tails.index(pair) print "".join(result) # => abba
ãµããµãããããæãã¤ãã人ã¯ãã£ããä½ãèãã¦ãã¦æãã¤ãããã ãããªããããããªãã
-
-
-
- -
-
-
BlockSortingã£ã¦ããããã¾ã æ®éã«å ¨é¨ã½ã¼ããã¦ãã¾ã£ã¦ããããBWTã¨å¼ã¶ã¹ããªã®ããªã
試ãã«ãã®ã½ã¼ã¹ãBWTãã¦ã¿ãããããªã£ãã確ãã«ç¸®ã¿ããããã ã