Skip to main content
. 2022 Apr 26;22(9):3323. doi: 10.3390/s22093323
Algorithm 1. Pseudo-code for k-tree construction
input: D
output: T

1. Tπ ← create a new node with STπ=∅
2. for d∈D
3.   Tπ ← F(Tπ,d, 1)
4. end for

5. function Fn,d,i 
6.   j ← 1
7.   while i ≤ |d| do
8.    if j > |Sn| then            //full match, so travel deeper//
9.      if di = “0” then          //travel left child//
10.      nl ← F (nl, d, i)
11.     else if di = “1” then     //travel right child//
12.      nr ← F (nr, d,i)
13.     end if
14.     break while
15.    else if Snj ≠ di then      //partial match, so do splitting //
16.     m ← a new node            //create a new node for splitting//
17.      if di = “0” then           //create a left child//
18.      ml ← create a new node
19.      mr  ← n
20.     else if di="1” then       //create a right child//
21.      mr  ← create a new node
22.      ml ← n
23.     end if
24.     adjust Sm, Smr, Sml for nodes m, mr, and ml
25.     n ←m
26.     break while
27.    end if
28.     i←i+1; j←j+1
29.   end while
30.   output n 
31. end function