Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

That tree format (using parentheses) is also known as Newick format >> https://en.wikipedia.org/wiki/Newick_format

But you can also simply store the tree structure as a single array of ints (or longs) ... each node in the tree corresponds to a unique index position, and the value at that position is the index position of the node's parent (or it's own position if it's a top level node) ... good stuff.



Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: