{'fraction_non_alphanumeric': 0.020496224379719527, 'fraction_numerical': 0.0, 'mean_word_length': 5.3561643835616435, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
MATHEMATICAL ENGINEERING TECHNICAL REPORTS Balanced Ternary-Tree Representation of Binary Trees and Balancing Algorithms

In this paper, we propose novel representation of binary trees, named the balanced ternary-tree representation. We examine flexible division of binary trees in which we can divide a tree at any node rather than just at the root, and introduce the ternary-tree representation for the flexible division. Due to the flexibility of division, for any binary tree, balanced or ill-balanced, there is always a balanced ternary tree representing it. We also develop three algorithms for generating balanced ternary-tree representation from binary trees and for rebalancing the ternary-tree representation after a small change of the shape. We not only show theoretical upper bounds of heights of the ternary-tree representation, but also report experiment results about the balance property in practical settings.