二叉树遍历图形化演示
标签:
•
文件类型: .zip
•
文件大小: 2.54MB
•
下载次数: 1
•
二叉树遍历图形化界面展示,课程设计。能够实现前序、中序、后序遍历。并实现良好的图形化界面及单步演示功能。
代码片段和文件信息
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2014-05-18 19:15 二叉树遍历
目录 0 2014-05-18 19:15 二叉树遍历BinaryTree1.1
文件 301 2014-03-18 08:01 二叉树遍历BinaryTree1.1.classpath
文件 378 2014-03-18 08:01 二叉树遍历BinaryTree1.1.project
目录 0 2014-05-18 19:15 二叉树遍历BinaryTree1.1.settings
文件 598 2014-03-18 08:01 二叉树遍历BinaryTree1.1.settingsorg.eclipse.jdt.core.prefs
目录 0 2014-05-18 19:15 二叉树遍历BinaryTree1.1in
目录 0 2014-05-18 19:15 二叉树遍历BinaryTree1.1ins
文件 968 2014-05-05 22:58 二叉树遍历BinaryTree1.1insBinTreeTraverse2$Node.class
文件 4586 2014-05-05 22:58 二叉树遍历BinaryTree1.1insBinTreeTraverse2.class
文件 851 2014-05-05 22:58 二叉树遍历BinaryTree1.1inslogin$1.class
文件 781 2014-05-05 22:58 二叉树遍历BinaryTree1.1inslogin$2.class
文件 979 2014-05-05 22:58 二叉树遍历BinaryTree1.1inslogin$ImageButton.class
文件 1251 2014-05-05 22:58 二叉树遍历BinaryTree1.1inslogin$NewPanel.class
文件 1782 2014-05-05 22:58 二叉树遍历BinaryTree1.1inslogin.class
文件 963 2014-05-05 22:58 二叉树遍历BinaryTree1.1insmyEditor$1.class
文件 830 2014-05-05 22:58 二叉树遍历BinaryTree1.1insmyEditor$10.class
文件 831 2014-05-05 22:58 二叉树遍历BinaryTree1.1insmyEditor$11.class
文件 831 2014-05-05 22:58 二叉树遍历BinaryTree1.1insmyEditor$12.class
文件 831 2014-05-05 22:58 二叉树遍历BinaryTree1.1insmyEditor$13.class
文件 833 2014-05-05 22:58 二叉树遍历BinaryTree1.1insmyEditor$14.class
文件 833 2014-05-05 22:58 二叉树遍历BinaryTree1.1insmyEditor$15.class
文件 833 2014-05-05 22:58 二叉树遍历BinaryTree1.1insmyEditor$16.class
文件 833 2014-05-05 22:58 二叉树遍历BinaryTree1.1insmyEditor$17.class
文件 833 2014-05-05 22:58 二叉树遍历BinaryTree1.1insmyEditor$18.class
文件 833 2014-05-05 22:58 二叉树遍历BinaryTree1.1insmyEditor$19.class
文件 827 2014-05-05 22:58 二叉树遍历BinaryTree1.1insmyEditor$2.class
文件 3238 2014-05-05 22:58 二叉树遍历BinaryTree1.1insmyEditor$3.class
文件 655 2014-05-05 22:58 二叉树遍历BinaryTree1.1insmyEditor$4.class
文件 824 2014-05-05 22:58 二叉树遍历BinaryTree1.1insmyEditor$5.class
文件 828 2014-05-05 22:58 二叉树遍历BinaryTree1.1insmyEditor$6.class
............此处省略25个文件信息
package bs;
import java.util.linkedList;
import java.util.List;
import java.util.Stack;
public class BinTreeTraverse2 {
static int[] array1 = new int[15];
static int[] array2 = new int[15];
static int temp = 0;
static int count = 0;
private static List nodeList = null;
static String output = new String(““);
public static void visit(Node node) {
// myEditor.textArea.setText(node.getData()+“ “);
output += node.getData() + “ “;
array2[count++] = node.getData();
// count++;
System.out.print(node.getData() + “ “);
// output += node.getData()+“ “;
}
// create binary tree from array.the data stored in level-order
public void createBinTree() {
nodeList = new linkedList();
for (int i = 0 len = array1.length; i < len; i++) {
nodeList.add(new Node(array1[i]));
}
int len = array1.length;
int lastRootIndex = (len >> 1) - 1;
for (int i = lastRootIndex; i >= 0; i--) {
Node root = nodeList.get(i);
int leftIndex = i * 2 + 1;
Node leftNode = nodeList.get(leftIndex);
// Node leftNode=new Node(array[leftIndex]);//this is wrong
root.setLeft(leftNode);
// 最后的那个根节点一定是有左孩子的。右孩子则不一定
int rightIndex = leftIndex + 1;
if (rightIndex <= len - 1) {
Node rightNode = nodeList.get(rightIndex);
root.setRight(rightNode);
}
}
}
public static String preOrder1() {
BinTreeTraverse2 tree = new BinTreeTraverse2();
tree.createBinTree();
count = 0;
preOrder(nodeList.get(0));
System.out.println();
return output;
}
public static String inOrder1() {
BinTreeTraverse2 tree = new BinTreeTraverse2();
tree.createBinTree();
count = 0;
inOrder(nodeList.get(0));
// inOrderStack(nodeList.get(0));
System.out.println();
return null;
}
public static String postOrder1() {
BinTreeTraverse2 tree = new BinTreeTraverse2();
tree.createBinTree();
count = 0;
// postOrderStack(nodeList.get(0));
postOrder(nodeList.get(0));
System.out.println();
return null;
}
public static void preOrderStack(Node root) {
Stack stack = new Stack();
Node p = root;
if (p != null) {
stack.push(p);
while (!stack.isEmpty()) {
p = stack.pop();
visit(p);
if (p.getRight() != null)
stack.push(p.getRight());
if (p.getLeft() != null)
stack.push(p.getLeft());
}
}
}
// nonRecursion inOrder Traverse
public static void inOrderStack(Node p) {
Stack stack = new Stack();
while (p != null || !stack.isEmpty()) {
// push all LeftChildwhen p has no LeftChildthat means it‘s
// rootit should be visited
while (p != null) {
stack.push(p);
p = p.getLeft();
}
if (!stack.isEmpty()) {
p = stack.pop();
visit(p);
p = p.getRight();
}
}
}
// nonRecursion postOrder Traverse
public sta
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2014-05-18 19:15 二叉树遍历
目录 0 2014-05-18 19:15 二叉树遍历BinaryTree1.1
文件 301 2014-03-18 08:01 二叉树遍历BinaryTree1.1.classpath
文件 378 2014-03-18 08:01 二叉树遍历BinaryTree1.1.project
目录 0 2014-05-18 19:15 二叉树遍历BinaryTree1.1.settings
文件 598 2014-03-18 08:01 二叉树遍历BinaryTree1.1.settingsorg.eclipse.jdt.core.prefs
目录 0 2014-05-18 19:15 二叉树遍历BinaryTree1.1in
目录 0 2014-05-18 19:15 二叉树遍历BinaryTree1.1ins
文件 968 2014-05-05 22:58 二叉树遍历BinaryTree1.1insBinTreeTraverse2$Node.class
文件 4586 2014-05-05 22:58 二叉树遍历BinaryTree1.1insBinTreeTraverse2.class
文件 851 2014-05-05 22:58 二叉树遍历BinaryTree1.1inslogin$1.class
文件 781 2014-05-05 22:58 二叉树遍历BinaryTree1.1inslogin$2.class
文件 979 2014-05-05 22:58 二叉树遍历BinaryTree1.1inslogin$ImageButton.class
文件 1251 2014-05-05 22:58 二叉树遍历BinaryTree1.1inslogin$NewPanel.class
文件 1782 2014-05-05 22:58 二叉树遍历BinaryTree1.1inslogin.class
文件 963 2014-05-05 22:58 二叉树遍历BinaryTree1.1insmyEditor$1.class
文件 830 2014-05-05 22:58 二叉树遍历BinaryTree1.1insmyEditor$10.class
文件 831 2014-05-05 22:58 二叉树遍历BinaryTree1.1insmyEditor$11.class
文件 831 2014-05-05 22:58 二叉树遍历BinaryTree1.1insmyEditor$12.class
文件 831 2014-05-05 22:58 二叉树遍历BinaryTree1.1insmyEditor$13.class
文件 833 2014-05-05 22:58 二叉树遍历BinaryTree1.1insmyEditor$14.class
文件 833 2014-05-05 22:58 二叉树遍历BinaryTree1.1insmyEditor$15.class
文件 833 2014-05-05 22:58 二叉树遍历BinaryTree1.1insmyEditor$16.class
文件 833 2014-05-05 22:58 二叉树遍历BinaryTree1.1insmyEditor$17.class
文件 833 2014-05-05 22:58 二叉树遍历BinaryTree1.1insmyEditor$18.class
文件 833 2014-05-05 22:58 二叉树遍历BinaryTree1.1insmyEditor$19.class
文件 827 2014-05-05 22:58 二叉树遍历BinaryTree1.1insmyEditor$2.class
文件 3238 2014-05-05 22:58 二叉树遍历BinaryTree1.1insmyEditor$3.class
文件 655 2014-05-05 22:58 二叉树遍历BinaryTree1.1insmyEditor$4.class
文件 824 2014-05-05 22:58 二叉树遍历BinaryTree1.1insmyEditor$5.class
文件 828 2014-05-05 22:58 二叉树遍历BinaryTree1.1insmyEditor$6.class
............此处省略25个文件信息
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。
评论列表(条)