what many efficient/elegant proceed parse boring list tree?


assume have boring list stores an systematic tree hierarchy:



id   name         parentid   order
1 'node 1' 0 10
2 'node 1.1' 1 10
3 'node 2' 0 20
4 'node 1.1.1' 2 10
5 'node 2.1' 3 10
6 'node 1.2' 1 20


here's diagram, where have [id] name. bottom node 0 fictional.




[0] root
/ \
[1] node 1 [3] node 2
/ \ \
[2] node 1.1 [6] node 1.2 [5] node 2.1
/
[4] node 1.1.1


what minimalistic proceed cost html (or text, matter) justly ordered, justly indented tree?



assume offer wholly have simple information structures (arrays hashmaps), imagination objects parent/children references, orm, framework, only your twin hands. list represented outcome set, accessed randomly.



pseudo formula plain english okay, definitely devising question.



bonus question: there essentially improved proceed store tree structure rdbms?






edits additions



to answer commenter's ('s) question: bottom node necessary, since never going displayed anyway. parentid = 0 party demonstrate "these tip level". method buttress defines nodes same progenitor going sorted.



the "result set" i spoke graphic an array hashmaps (to stay terminology). instance meant already there. answers additional mile make first, nonetheless thats okay.



the tree arbitrarily deep. any node have n children. i accurately have "millions entries" tree mind, though.



don't mistake choice node controlling ('node 1.1.1') something rest on. nodes equally good called 'frank' 'bob', controlling structure implied, merely readable.



i have posted possess fortitude guys lift pieces.



Comments

Popular posts from this blog

list macos calm editors formula editors

how hibernate @any-related annotations?

why does floated <input> control floated component slip over too distant right ie7, nonetheless firefox?