Answer the question
In order to leave comments, you need to log in
What algorithm should be used to build a nested tree?
There is an array like this:
[{
"Level": 0,
"Val": "1"
}, {
"Level": 0,
"Val": "2"
}, {
"Level": 1,
"Val": "2.1"
}, {
"Level": 1,
"Val": "2.2"
}, {
"Level": 2,
"Val": "2.2.1"
}, {
"Level": 3,
"Val": "2.2.1.1"
}, {
"Level": 0,
"Val": "3"
}, {
"Level": 1,
"Val": "3.1"
}]
[{
"Level": 0,
"Val": "1",
"Children": []
}, {
"Level": 0,
"Val": "2",
"Children": [{
"Level": 1,
"Val": "2.1",
"Children": []
}, {
"Level": 1,
"Val": "2.2",
"Children": [{
"Level": 2,
"Val": "2.2.1",
"Children": [{
"Level": 3,
"Val": "2.2.1.1",
"Children": []
}]
}]
}]
}, {
"Level": 0,
"Val": "3",
"Children": [{
"Level": 1,
"Val": "3.1",
"Children": []
}]
}]
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question