- 博客(5)
- 收藏
- 关注
原创 04-树5 Root of AVL Tree (25分)
An AVL tree is a self-balancing binary search tree. In an AVL tree, the heights of the two child subtrees of any node differ by at most one; if at any time they differ by more than one, rebalancing is
2016-12-30 20:57:00 496
原创 04-树4 是否同一棵二叉搜索树 (25分)
给定一个插入序列就可以唯一确定一棵二叉搜索树。然而,一棵给定的二叉搜索树却可以由多种不同的插入序列得到。例如分别按照序列{2, 1, 3}和{2, 3, 1}插入初始为空的二叉搜索树,都得到一样的结果。于是对于输入的各种插入序列,你需要判断它们是否能生成一样的二叉搜索树。输入格式:输入包含若干组测试数据。每组数据的第1行给出两个正整数NN (\le 10≤10)和LL,分别是每
2016-12-20 20:09:06 355
原创 03-树3 Tree Traversals Again (25分)
An inorder binary tree traversal can be implemented in a non-recursive way with a stack. For example, suppose that when a 6-node binary tree (with the keys numbered from 1 to 6) is traversed, the stac
2016-12-14 19:22:05 418
原创 03-树2 List Leaves (25分)
Given a tree, you are supposed to list all the leaves in the order of top down, and left to right.Input Specification:Each input file contains one test case. For each case, the first line give
2016-12-07 16:16:56 838
原创 03-树1 树的同构 (25分)
给定两棵树T1和T2。如果T1可以通过若干次左右孩子互换就变成T2,则我们称两棵树是“同构”的。例如图1给出的两棵树就是同构的,因为我们把其中一棵树的结点A、B、G的左右孩子互换后,就得到另外一棵树。而图2就不是同构的。图1图2现给定两棵树,请你判断它们是否是同构的。输入格式:输入给出2棵二叉树树的信息。对于每棵树
2016-12-06 08:26:00 468
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人