| Inputs: {Ψ(Q, Ai), HASH, F}, List<TreeNode> |
| Outputs: deputy root node R∗ |
| BUILDTREE(M,n,d,H,i)//Achievements: file information M, n blocks, tree height d, |
| hash function H, traversal variable i. |
| FILE INITIALIZATION(M) |
| WHILE(CUR_DEPTH < d)//Build n-tree layer by layer until d-layer. |
| { |
| TreeNode tmp_father = new TreeNode () |
| HASH = 0//Current hash value |
| List<TreeNode> tmp_up//Build temporary parent node |
| FOR i = 1 TO m.size |
| { |
| IF (tmp_up.size() < n)//Have not formed a block, continue to traverse the nodes |
| { |
| tmp_up.add(m[i]) |
| hash = H(hash, m[i]- > hash)//Keep taking hash values |
| m[i]- > Father = tmp_father//Set the father of the current node as “temporary father node” |
| tmp_father - > Child.add(m[i])//Add a child to the “temporary father node” |
| } |
| ELSE |
| { |
| tmp_father- > hash = hash |
| IF (CUR_DEPTH = = d/2)//Mark the deputy root node and add it to the result |
| { |
| tmp_father- > Q = 1 |
| R∗.add(tmp_father) |
| } |
| ELSE |
| { |
| tmp_father- > Q = 0 |
| } |
| up.add(tmp_father) |
| tmp_up.clear() |
| tmp_father = new TreeNode() |
| i i-1 |
| } |
| m = up; |
| up.clear(); |
| ++CUR_DEPTH; |
| } |
| return R∗ |