摘要:Little Valentine liked playing with binary trees very much. Her favorite game was constructing randomly looking binary trees with capital letters in the nodes.This is an example of one of her creations:D/ \/ \B E/ \ \/ \ \A C G//FTo record her trees for future generations, she wrote down two strings
阅读全文
摘要:As we know,the shape of a binary search tree is greatly related to the order of keys we insert. To be precisely:1.insert a key k to a empty tree, then the tree become a tree withonly one node;2.insert a key k to a nonempty tree, if k is less than the root ,insertit to the left sub-tree;else insert k
阅读全文
摘要:A binary tree is a finite set of vertices that is either empty or consists of a root r and two disjoint binary trees called the left and right subtrees. There are three most important ways in which the vertices of a binary tree can be systematically traversed or ordered. They are preorder, inorder a
阅读全文
摘要:An encoding of a set of symbols is said to be immediately decodable if no code for one symbol is the prefix of a code for another symbol. We will assume for this problem that all codes are in binary, that no two codes within a set of codes are the same, that each code has at least one bit and no mor
阅读全文
摘要:判断两序列是否为同一二叉搜索树序列Input开始一个数n,(1#include inta[1024],b[1024];voidcta(charc,inti)//这个和下面可以合并一个,用指针传递数组{ if(a[i]==0) {a[i]=c;return;} if(a[i]>c) cta(c,ic) ctb(c,im2?m2:m1;//递归回程,判断树是否一样}intmain(){inti,n; charc[13],s[13]; while(scanf("%d",&n),n) { memset(a,0,sizeof(a)); scanf("%s&qu
阅读全文