Description
Profile structural UTF-16 edge depth independently of grapheme or Unicode-code-point length.
A trie stores literal words as root-to-node character paths, with terminal flags marking complete words. A terminal can also have children, and an existing prefix path need not be a stored word. This family uses one UTF-16 code unit per ordinary edge, so code-unit length differs from a displayed character or Unicode code-point count.
Profile structural UTF-16 edge depth independently of grapheme or Unicode-code-point length.
When to use this tool
Use this tool to profile structural UTF-16 edge depth independently of grapheme or Unicode-code-point length.
How to use the tool and how it works
- Enter nodesJson using the definitions below. Serialize JSON text fields in the decoded shape shown below.
- Run the operation. Resolve input-format errors before interpreting an output.
- Read result.depths, result.maximum, using the stated boundary, ordering, sign and absence conventions.
Reconstruct each node’s root-to-node word and use its UTF-16 length as depth. Return source-order {id,depth} records and their maximum; the root has depth zero.1
| Input field | Meaning and units | Accepted input |
|---|---|---|
| nodesJson | JSON array of {id,parent,character,terminal} nodes under the complete root-zero trie rules below. | Text, at most 8,192 UTF-16 code units; narrower grammar/range rules also apply. |
These decoded structures show the examples inside JSON text fields. Supply their serialized JSON strings as input.
{
"nodesJson": [
{
"id": 0,
"parent": null,
"character": "",
"terminal": false
},
{
"id": 1,
"parent": 0,
"character": "a",
"terminal": true
},
{
"id": 2,
"parent": 1,
"character": "b",
"terminal": true
},
{
"id": 3,
"parent": 0,
"character": "b",
"terminal": true
}
]
} | Output field | Interpretation |
|---|---|
| result | Object containing the fields below. |
| result.depths | Source-order {id,depth} root-distance records in code units. |
| result.maximum | Largest root-to-node code-unit depth. |
{
"input": {
"nodesJson": "[{\"id\": 0, \"parent\": null, \"character\": \"\", \"terminal\": false}, {\"id\": 1, \"parent\": 0, \"character\": \"a\", \"terminal\": true}, {\"id\": 2, \"parent\": 1, \"character\": \"b\", \"terminal\": true}, {\"id\": 3, \"parent\": 0, \"character\": \"b\", \"terminal\": true}]"
},
"output": {
"result": {
"depths": [
{
"id": 0,
"depth": 0
},
{
"id": 1,
"depth": 1
},
{
"id": 2,
"depth": 2
},
{
"id": 3,
"depth": 1
}
],
"maximum": 2
}
}
} Limitations and assumptions
- Depth counts code units, not Unicode code points or displayed glyphs.
- Ordinary node tables have at most 128 nodes with distinct IDs 0–127, one root ID 0 with empty character and null parent, unique parent/character edges, complete acyclic parent links and a boolean terminal flag. Every nonroot character is exactly one UTF-16 code unit.
- Every declared outer field is required and unknown outer fields are rejected. Strings and JSON text have size limits, lists are bounded to 128 entries, and JSON nesting/node counts are bounded. Tighter operation-specific bounds stated above take precedence.
- Ordinary numeric outputs must be finite and within safe-integer magnitude. Exact large lengths/counts use decimal strings. Original record indexes and code-unit positions are zero-based; span ends are exclusive unless stated otherwise.
Alternative or Complementary methods
Choose word membership, prefix existence, completion or ranking according to the question. Normalize text separately if needed; these operations preserve exact code units and caller order.
References
Similar or alternative tools
- Prefix Trie Completion Explicit Score Order
Order explicit scored prefix completions by descending score with stable source ties, retaining distinct occurrence IDs; no authoritative autocomplete dictionary.
- Prefix Trie Compressed Edge Node Expander
Expand an explicit compressed rooted trie edge table into stable insertion-code-unit nodes, validating complete unique-parent acyclic structure and unambiguous outgoing first characters; IDs are reallocated, not preserved.