线索二叉树
Posted sz_zzm
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了线索二叉树相关的知识,希望对你有一定的参考价值。
package cn.firstflag.crm.service; import jxl.common.Logger; /** * * @author zhanmin.zheng * */ public class ThreadTree { private Logger log = Logger.getLogger(getClass()); private Integer childFlag = 0; private Integer threadFlag = 1; public class Node <T> { private T data; private Integer leftFlag = childFlag; private Integer rightFlag = childFlag; private Node leftChildren; private Node rightChildren; public Node() { super(); } public Node(T data) { super(); this.data = data; } } static Node pre = null; public void create(Node node) { if (node == null) return; if (node.leftChildren == null) { node.leftFlag = 1; } if (node.rightChildren == null) { node.rightFlag = 1; } if (node.leftFlag == 1) { node.leftChildren = pre; } if (pre != null && pre.rightFlag ==1) { pre.rightChildren = node; } pre = node; create(node.leftChildren); create(node.rightChildren); } public Node foreach(Node node) { while (node.leftFlag == 1) { node = node.leftChildren; } while (node.rightFlag == 1) { log.debug("pass " + node.data); node =node.rightChildren; } return node; } }
以上是关于线索二叉树的主要内容,如果未能解决你的问题,请参考以下文章