在trie树中使用的双数组

时间:2012-12-19 07:35:51

标签: c trie

我尝试通过this link中的双数组树来理解trie树实现。

  1. 在碰撞时,它应该重新定位。从伪代码,为什么它还应该更新check[base[base[s] + c] + d]base[b+c]
  2. 任何人都可以用简单的语言解释它吗?

    Procedure Relocate(s : state; b : base_index)
    { Move base for state s to a new place beginning at b }
    begin
        foreach input character c for the state s
        { i.e. foreach c such that check[base[s] + c]] = s }
        begin
            check[b + c] := s;     { mark owner }
            base[b + c] := base[base[s] + c];     { copy data }
            { the node base[s] + c is to be moved to b + c;
              Hence, for any i for which check[i] = base[s] + c, update check[i] to b + c }
            foreach input character d for the node base[s] + c
            begin
                check[base[base[s] + c] + d] := b + c
            end;
            check[base[s] + c] := none     { free the cell }
        end;
        base[s] := b
    end
    

0 个答案:

没有答案