Answer the question
In order to leave comments, you need to log in
What algorithm should be used to parse these product categories and turn them into a tree structure?
I’ve been suffering for an hour, I just can’t figure out how to turn this structure into a normal working view
<item>
<ID>
</ID>
<name>
</name>
<about>
</about>
<price>
</price>
<manufacture>
</manufacture>
<category2>
</category2>
<category1>
</category1>
<category0>
</category0>
</item>
<item>
<ID>
</ID>
<name>
</name>
<about>
</about>
<price>
</price>
<manufacture>
</manufacture>
<category2>
</category2>
<category1>
</category1>
<category0>
</category0>
</item>
......
Answer the question
In order to leave comments, you need to log in
prefix tree. Split by category. Can be done with hashes.
The result is your tree.
Prefix tree: https://en.wikipedia.org/wiki/Trie
--------
Pseudocode
Для каждого <item>:
Взять категории по порядку. [cat1,cat2,cat3]
Уложить этот путь в trie.
В качестве листа, указать все остальные<не категории> элементы item
Готово
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question