1040 Longest Symmetric String (25 分) Given a string, you are supposed to output the length of the longest symmetric sub-string. For example, given Is PAT&TAP symmetric?, the longest symmetric sub-string is s PAT&TAP s, hence you must output 11.…
题目:一个二叉树,如果每一个层的结点数都达到最大值,则这个二叉树就是完美二叉树.对于深度为 D 的,有 N 个结点的二叉树,若其结点对应于相同深度完美二叉树的层序遍历的前 N 个结点,这样的树就是完全二叉树. 给定一棵完全二叉树的后序遍历,请你给出这棵树的层序遍历结果. 输入格式:输入在第一行中给出正整数 N(≤30),即树中结点个数.第二行给出后序遍历序列,为 N 个不超过 100 的正整数.同一行中所有数字都以空格分隔. 输出格式:在一行中输出该树的层序遍历序列.所有数字都以 1 个空格分隔…
A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties: The left subtree of a node contains only nodes with keys less than the node's key. The right subtree of a node contains only nodes with keys greate…
1020 Tree Traversals (25分) Suppose that all the keys in a binary tree are distinct positive integers. Given the postorder and inorder traversal sequences, you are supposed to output the level order traversal sequence of the corresponding binary tre…