What would be the time complexity for the encode function? I think it should be O(v + e) + O(v * k * clogc), where v = num nodes, e = num edges, c = number of children & k = length of subtree encoding. For every node in the tree, we are sorting labels array which consists of node.children.size() (c) strings each of length let's say k (multiple of 2) so it would take (k * clogc) in sorting encodings of subtrees and for every v vertex in the tree time would be O(v * k*clogc). Is this analysis correct? If yes how to express k and c in terms of v and e.
In last video, each treeNode is defined as a class with id, parent and children. Apparently each node is only linked only to its neighbors now using adjacency list and the class is reduced to an integer id. It would be helpful to point out the gap since the representation changed a bit and it affects the implementation.