# coding=utf-8 def BWTEncode(str): str = str + '#' size = len(str) bwtstr = ['0'] * size result = [] result.append(str) for j in range(size): for i in range(size): if i == size-1: bwtstr[0] = str[i] else: bwtstr[i+1] = str[i] bstr = '' for i in range(len(bwtstr)): bstr += bwtstr[i] if j == size-1: break else: result.append(bstr) str = bstr result = sorted(result) l = '' for i in range(len(result)): l += result[i][-1] return l def strtolist(str): result = [] for i in range(len(str)): result.append(str[i]) return result def listtostr(list)
Python实现BWT算法()
最新推荐文章于 2025-02-06 23:34:35 发布