Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/algorithm/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Algorithm 按位Trie查找是如何工作的_Algorithm_Data Structures_Full Text Search_Bit Manipulation_Trie - Fatal编程技术网

Algorithm 按位Trie查找是如何工作的

Algorithm 按位Trie查找是如何工作的,algorithm,data-structures,full-text-search,bit-manipulation,trie,Algorithm,Data Structures,Full Text Search,Bit Manipulation,Trie,我最近一直在研究数据结构,不断遇到“按位Trie” 我知道trie是如何工作的,但我不了解以下内容: public class Node { Node[] _nodes = new Node[27]; // 26 = A-Z + NULL public Node Next(char c) { if (c == '$') return _nodes[26]; return _nodes[c - 'A'];

我最近一直在研究数据结构,不断遇到“按位Trie”

我知道trie是如何工作的,但我不了解以下内容:

public class Node
{
    Node[] _nodes  = new Node[27]; // 26 = A-Z + NULL

    public Node Next(char c)
    {
        if (c == '$')
            return _nodes[26];

        return _nodes[c - 'A'];
    }
}
  • 按位树节点的数据结构
  • 作为比较,穷人实现的简单固定长度数组Trie如下所示:

    public class Node
    {
        Node[] _nodes  = new Node[27]; // 26 = A-Z + NULL
    
        public Node Next(char c)
        {
            if (c == '$')
                return _nodes[26];
    
            return _nodes[c - 'A'];
        }
    }
    
    类似的东西在“按位树”中会是什么样子

    编辑

    在@samsag注释之后,它正在计算前导零,而不是设置的位数

  • 如何计算“
    1
    ”位的数量有帮助
  • e、 比如说

    EOL   = 000 (0 bits set)    
    A     = 001 (1 bit set)
    B     = 010 (1 bit set)
    C     = 011 (2 bits set)
    D     = 100 (1 bit set)
    E     = 101 (2 bits set)
    F     = 111 (3 bits set)
    
    当有这么多冲突时,比特计数有什么帮助?
    我需要执行什么样的算法/散列/逐位操作才能利用位计数?

    您确定该算法涉及到计数集位而不是前导零吗?你能链接到一个例子吗?@samsag你是对的,它正在计算前导(第一个位集,而不是位集的数量)!真不敢相信我一直在追根究底,因为我解释错了什么!提到使用clz获得第一个位集!不知道我为什么这样解释它!现在更有意义了