I have a DataTable with all of my nodes in it. They were serialized to database. I want to create an object graph (hierarchical) representation of the data. There seem to be a few methods for doing this.
This article describes a high order method (meaning it involves lots of searching of the DataTable before the tree is fully built)
Is there an Order-N approach? In my case, I have pre-sorted the nodes of the tree in the DataTable into the in-order form. Meaning, the first row shows a NULL for the parent, because it's the root. Each subsequent row is sorted in in-order notation.
I seem to recall an Order-N approach from my school days. But I can't remember.
My DataTable schema resembles this:
- NodeID - int
- ParentNodeId - nullable
- Data - string