数据处理 | Tree2List&&List2Tree
准备工作
典型的数结构
1 | const treeData = [ |
平铺list结构
1 | const listData = [ |
List转Tree
递归
1 | function list2tree(listData) { |
双层循环
1 | function list2tree(listData) { |
使用map
1 | function list2tree(listData) { |
Tree转List
BFS
1 | function tree2list(treeData) { |
DFS
1 | function tree2list(treeData) { |