algorithm - 在哈希树中,非叶子节点是直接数据的哈希,还是子哈希的哈希?

标签 algorithm data-structures hashtree

我正在寻找the wikipedia article for hash trees ,我对他们的图表有点困惑。

叶节点显然包含底层数据的散列。

哈希树中的叶节点是否不同于任何非叶节点?非叶节点包含数据的哈希值,还是哈希值的哈希值

给定这张图:

Hash tree diagram

以下哪个是 Hash 1 的哈希值?

  1. 哈希 1-0 + 哈希 1-1
  2. 数据 block 002 + 数据 block 003

或者哈希树是否根据应用程序(rsync、P2P 网络、Git 等)而根本不同?

最佳答案

这是 wiki 文章所说的:

Nodes further up in the tree are the hashes of their respective children. For example, in the picture hash 0 is the result of hashing hash 0-0 and then hash 0-1. That is, hash 0 = hash( hash 0-0 || hash 0-1 ) where || denotes concatenation.

但我真的相信开发人员可以自定义树和算法,使用不同的哈希函数等,针对不同的数据、速度或内存等对其进行优化。

关于algorithm - 在哈希树中,非叶子节点是直接数据的哈希,还是子哈希的哈希?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8411144/

相关文章:

python - 在 Python 中实现类似缓冲区的结构

python - Python 的 `in` 关键字是否执行线性搜索?

python - collections.ChainMap 的目的是什么?

mysql - 设计复杂的 SQL 结构

python - 反向树构建(有奇数个 child )

使用自定义类类型作为键的 C++ unordered_map

algorithm - 在 O(nlog*n) 和 O(n) 之间?

python - 算法:类(class)顺序

algorithm - 包含超集