二叉树在数据结构的教学中是非常重要的一类非线性结构,在上机编程和调试的过程中如何快速有效直观地显示这类非线性结构直接影响着教与学的效率,为此提出了一种文本模式的二叉树结构显示方法;该方法利用’-’、’/’和’\’三种特殊字符把子结点和父结点连接起来,使用队列对二叉树进行层序输出。在队列中采用空指针NULL代表空结点,同时用一个新结点end表示每一层的结束。该方法不仅适用于顺序存储的二叉树也适用于链式存储的二叉树,进行适当修改也可顺利地显示3阶B一树,因此可以作为数据结构教与学的有效手段之一。
Binary tree is very important nonlinear structure in the data structures, how to display the binary tree effectively is essential to the related teaching and learning. A text-mode display method for binary tree was proposed, three characters ('_', '/' and '/ ') were used to connect the parent and children nodes, queue technique was used to export binary tree by level-order, the empty node is represented by the NULL pointer and one new node is created to denote the end of one level in the level-order queue. The method is usable for both of sequence and linked binary trees, is applicable for display of 3-order B_tree by small modification, and is valuable to improve the teaching and learning.