Tree/tree_serialization library

🌳 Tree Serialization and Deserialization

Converts binary trees to and from string representations. Uses a level-order traversal with null markers for missing children.

Time complexity: O(n) where n is the number of nodes Space complexity: O(n) for storing the serialized string

Example:

final root = BinaryTreeNode<int>(10);
root.left = BinaryTreeNode<int>(5);
root.right = BinaryTreeNode<int>(15);
final serialized = serializeTree(root);
// serialized: "10,5,15,null,null,null,null"
final deserialized = deserializeTree(serialized);
// deserialized has the same structure as root

Functions

deserializeTree<T>(String data) → BinaryTreeNode<T>?
Deserializes a string back to a binary tree
serializeTree<T>(BinaryTreeNode<T>? root) → String
Serializes a binary tree to a string representation