Home > Backend Development > PHP Tutorial > 层序遍历,或者说是结构完全三叉树

层序遍历,或者说是结构完全三叉树

WBOY
Release: 2016-06-13 13:10:06
Original
1885 people have browsed it

层序遍历,或者说是构造完全三叉树
三叉树存储结构如下


| id | parent | l_child | m_child | r_child | 



我现在需要 指定一个节点,插入一个孩子节点,要求这个节点距离指定节点的距离最小,并且按照优先级 l->m->r 的顺序插入进去,也就是说,当达插入的节点达到某个数量的时候,能成为一颗完全三叉树

------解决方案--------------------
....

}
}
return a($tree,$uid);
}

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template