public class BinaryTree {
public static void main(String[] args) {
int[] data = new int[10];
for(int i = 0; i < data.length; i++) {
data[i] = (int)(Math.random() * 100) + 1;
System.out.prin...
分类:
编程语言 时间:
2015-08-07 14:45:33
阅读次数:
184
题目:
Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.
题解:将一个有序链表转成二叉排序树,如果是一棵相对平衡的排序树,应该是这样的,链表中间那个节点为树的根节点,根节点的左子树节点应该是根节点左边那部分的中间节点,根节点的...
分类:
编程语言 时间:
2015-07-30 09:33:16
阅读次数:
150
package com.cn.binarytree.utils;/** * @author 刘利娟 liulijuan132@gmail.com * @version 创建时间:2014年7月20日 下午2:03:30 类说明: */class Node { Node left; Node righ...
分类:
编程语言 时间:
2015-07-25 18:02:45
阅读次数:
116
题目描述线索二叉树概念
1.定义
n个结点的二叉链表中含有n+1个空指针域。利用二叉链表中的空指针域,存放指向结点在某种遍历次序下的前趋和后继结点的指针(这种附加的指针称为”线索”)。这种加上了线索的二叉链表称为线索链表,相应的二叉树称为线索二叉树(Threaded BinaryTree)。根据线索性质的不同,线索二叉树可分为前序线索二叉树、中序线索二叉树和后序线索二叉树三种。...
分类:
其他好文 时间:
2015-07-22 06:58:27
阅读次数:
169
二叉树类代码:package binarytree;import linkqueue.LinkQueue;public class BinaryTree { class Node { public Object data; public Node lchild; public Node rch...
分类:
编程语言 时间:
2015-07-19 16:10:03
阅读次数:
139
很久没有接触二叉树了,写这个当作练手,接下来会比较详细地实现二叉树的各个功能及应用。/** BinaryTree.cpp* Author: Qiang Xiao* Time: 2015-07-17*/#include#includeusing namespace std;templa...
分类:
编程语言 时间:
2015-07-18 00:27:02
阅读次数:
124
题目:
Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and alternate between).
For example:
Give...
分类:
编程语言 时间:
2015-07-09 17:59:13
阅读次数:
112
题目:
Given a binary tree, return the postorder traversal of its nodes' values.
For example:
Given binary tree {1,#,2,3},
1
2
/
3
return [3,2,1].
解题:
递归的还是和前面中...
分类:
编程语言 时间:
2015-07-09 11:16:06
阅读次数:
179
题目:
Given a binary tree, return the inorder traversal of its nodes' values.
For example:
Given binary tree {1,#,2,3},
1
2
/
3
return [1,3,2].
解题:
中序遍历一颗二叉树,如...
分类:
编程语言 时间:
2015-07-08 13:07:37
阅读次数:
141
将数组构造成二叉查找树:/*public class BinaryTree { private Node root; *//** * 内部类实现结点类,可提高安全性 * *//* private static class Node { ...
分类:
其他好文 时间:
2015-07-07 12:56:12
阅读次数:
151