How to serialize and deserialize a binary tree
Anonymous
A possible solution is to have 3 elements in a line, comma-separated. The first value represents the parent value, and the 2 other values are the left/right children. (if there are duplications then you can use an ID for each node, and have the value in that line as well) For example: <br> root, a, b<br> a, c, d<br> c, e, f<br> b, x, y<br> Is a binary tree where a and b are the children of 'root', c and d are children of 'a' and so on.
Check out your Company Bowl for anonymous work chats.