Problem Description
There are many questions about the tree, most of them are Binary tree. But now, I’m tired of it. In this problem, we will not talk about the binary tree again, we discuss the tree which has three sub-trees, we called it extend tree;

The extend tree is orderly, it means that every integer n(n>=0) correspond to one unique extend tree and each extend tree correspond to one unique number. The tree is numbered using the following scheme:

1. The empty tree is numbered 0;
2. The single-node tree is numbered 1;
3. All extend trees that has m nodes correspond to a smaller integer than the tree which has more than m nodes.
4. Any extend tree having m nodes with left, mid and right sub-trees L ,M and R is numbered n; such that all trees having m nodes numbered > n have either Left sub-trees numbered higher than L, or A left sub-tree = L and a mid sub-tree numbered higher than M, or a left sub-tree = L a mid sub-tree = M and a right sub-tree numbered higher than R.

The first 18 extend trees are show below:

Your job for this problem is to output a extend tree when its order number is given.

Input
The first line contains a single positive integer T( T <= 3000 ), indicating the number of datasets.
Each instance consist of a single integer n, where 1<= n <=10^14.

Output
For each problem instance, you should output one line containing the tree corresponding to the order number for that instance. To print out the tree, use the following scheme:
A tree with no children should be output as X. A tree with left, mid and right sub-trees L M, and R should be output as (L)(M)(R)X, where L M, and R are the representations of L M, and R.
If L is empty, just output (M)(R)X.
If M is empty, just output (L)(R)X.
If R is empty, just output (L)(M)X.
If L and M is empty, just output (R)X.
...
The answer of other conditions has the same format.

Sample Input
10
1
2
3
4
5
6
7
8
9
10

Sample Output
Case #1: X
Case #2: (X)X
Case #3: (X)X
Case #4: (X)X
Case #5: ((X)X)X
Case #6: ((X)X)X
Case #7: ((X)X)X
Case #8: (X)(X)X
Case #9: ((X)X)X
Case #10: ((X)X)X

C语言数据结构中，二叉树的clear和destroy有什么区别？
C语言数据结构中，二叉树的clear（清空）和destroy有什么区别？ 1. destroy是将所有结点都free掉，并且让指向树根的指针=NULL。 2. 那么clear（清空）又是什么呢？和destroy的区别是什么呢？

【c语言数据结构】遍历二叉树

Problem Description There are some queries on a tree which has n nodes. Every query is described as two integers (X, Y).For each query, you should find the maximum weight of the edges in set E, which satisfies the following two conditions. 1) The edge must on the path from node X to node 1. 2) The edge’s weight should be lower or equal to Y. Now give you the tree and queries. Can you find out the answer for each query? Input The first line of the input is an integer T, indicating the number of test cases. For each case, the first line contains an integer n indicates the number of nodes in the tree. Then n-1 lines follows, each line contains three integers X, Y, W indicate an edge between node X and node Y whose value is W. Then one line has one integer Q indicates the number of queries. In the next Q lines, each line contains two integers X and Y as said above. Output For each test case, you should output Q lines. If no edge satisfy the conditions described above，just output “-1” for this query. Otherwise output the answer for this query. Sample Input 1 3 1 2 7 2 3 5 4 3 10 3 7 3 6 3 4 Sample Output 7 7 5 -1

Problem Description bobo has a tree, whose vertices are conveniently labeled by 1,2,…,n. At the very begining, the i-th vertex is assigned with weight wi. There are q operations. Each operations are of the following 2 types: Change the weight of vertex v into x (denoted as "! v x"), Ask the total weight of vertices whose distance are no more than d away from vertex v (denoted as "? v d"). Note that the distance between vertex u and v is the number of edges on the shortest path between them. Input The input consists of several tests. For each tests: The first line contains n,q (1≤n,q≤105). The second line contains n integers w1,w2,…,wn (0≤wi≤104). Each of the following (n - 1) lines contain 2 integers ai,bi denoting an edge between vertices ai and bi (1≤ai,bi≤n). Each of the following q lines contain the operations (1≤v≤n,0≤x≤104,0≤d≤n). Output For each tests: For each queries, a single number denotes the total weight. Sample Input 4 3 1 1 1 1 1 2 2 3 3 4 ? 2 1 ! 1 0 ? 2 1 3 3 1 2 3 1 2 1 3 ? 1 0 ? 1 1 ? 1 2 Sample Output 3 2 1 6 6

Problem Description Given n labeled vertices, there are nn-2 different trees. The number is too large, but Wiskey want to use a way to encode the tree that make a unique sequence associated with the labeled tree. Follow this way: 1.Select the vertex u which degree is 1 and the labeled number is the minimum. Example, u = 4. 2.Select the neighbor v of u, exists the edge which u to v. Example, v = 1. 3.Delete the edge from the tree. Example, the edge of 1-4 will be deleting. 4.Repeat the first step, until only two vertices left. 5.We will get the sequence {u1, u2… un-2} and {v1, v2… vn-2}. Now, give you the v sequence, tell me the u sequence. Input First line will contain one integer mean how many cases will follow by. N represents the number of vertices, and the label start from 1. (3 <= N <= 100). The next N-2 numbers mean the v sequence. Output Output the u sequence in one line, separate by a blank space. Sample Input 1 8 1 2 1 3 3 5 Sample Output 4 6 2 1 7 3

Problem Description Consider a two-dimensional space with a set of points (xi, yi) that satisfy xi < xj and yi > yj for all i < j. We want to have them all connected by a directed tree whose edges go toward either right (x positive) or upward (y positive). The figure below shows an example tree. Write a program that finds a tree connecting all given points with the shortest total length of edges. Input The input begins with a line that contains an integer n (1 <= n <= 1000), the number of points. Then n lines follow. The i-th line contains two integers xi and yi (0 <= xi, yi <= 10000), which give the coordinates of the i-th point. Output Print the total length of edges in a line. Sample Input 5 1 5 2 4 3 3 4 2 5 1 1 10000 0 Sample Output 12 0

Problem Description Alice and Bob are playing games again! This time, they invent a new game called "Color the Tree". They draw a tree with N nodes and, certainly, (N-1) edges connecting them to assure a path between each pair of the nodes. But the tree they play with is a little special - each edge is assigned to a color and a specific value. Initially, the value of each edge is settled while the colors are all white. When the game starts, Alice and Bob each choose a node as her/his starting node. In each round, Alice firstly makes a move from her current node to another through an edge with a color of white or red, and if the edge is white, she colors it to red. After that, Bob makes a similar move through a white or blue edge from his current node, and if the edge is white, he colors it to blue. The game keeps going on until all the edges are colored to either red or blue. Alice's goal is to maximize the sum of values of the red edges, and Bob, wants to maximize that of the blue edges. Given the starting node of them, figure out the maximum sum that Alice is able to obtain if both of them take the best strategy in each round. Input The first line of the input contains a single integer T, indicating there are T test cases. In each case, the first line contains two integers N and M, which denotes the number of nodes and queries. Each of the following (N-1) lines contains a triple of integers (a,b,c), indicating there is an edge connecting node a and node b with a value of c. The following M lines describe the queries. Each of the M lines consists of two integers A and B, indicating the starting node of Alice and Bob, respectively. (2≤N≤100000,1≤M≤100000,1≤a,b,A,B≤N,1≤c≤1000) Output For each query, output the maximum sum that Alice can obtain, one per line. Sample Input 2 2 1 1 2 3 1 2 3 2 1 2 3 1 3 1 2 3 1 3 Sample Output 3 3 4
C语言设计对二叉树和有向图存储和运算算法程序
C语言设计对二叉树和有向图存储和运算算法程序 （1）创建由输入文件input.txt指定的随机字母（结点个数不小于8个）的二叉树 （2）设计并实现递归中序遍历二叉树的算法程序，遍历结果输出到指定文件output.txt （3）设计并实现按层次遍历二叉树的算法程序，遍历结果输出到指定文件output.txt （4）创建由输入文件input.txt指定的随机字母（结点个数不小于10个）的有向图，设计并实现非递归的有向图广度优先遍历算法程序，遍历结果输出到指定文件output.txt
C语言求二叉树结点个数？
c语言中的先序插入二叉树怎么写？
#include<stdio.h> #include<stdlib.h> #include<string.h> #define MAX 100 typedef struct node {char name[10] ; struct node *lchild, *rchild; }BTree; BTree *q[MAX]; /*存储队列元素的数组*/ BTree *CreatBtree(); /* 创建二叉家族树 */ void ScanLevel(BTree *bt); /* 按层次顺序遍历二叉家族树 */ int FindAncestry(BTree *bt,char *ch,int flag); void Precreat(BTree *bt); void InorderTraverse(BTree *bt); int main() { BTree *head; int ch; char cname[10]; while(1) { printf("请选择以下操作：\n"); printf ("一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一\n"); printf("1……创建一个二叉家族树\n"); printf("2……按层次输出二叉家族树\n"); printf("3……输出某个成员的所有祖先成员\n"); printf("4……结束程序\n"); printf ("一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一\n"); printf("请选择(1--4)："); scanf("%d",&ch); getchar(); switch(ch) { case 1: /* 创建二叉家族树 */ Precreat(head); printf("\n二叉家族树创建成功！\n"); printf("\n请按任意键返回主菜单..."); getchar(); break; case 2:printf("按层次输出二叉家族树：\n");/* 按层次输出家族树 */ ScanLevel(head); printf("\n中序遍历输出二叉树\n"); InorderTraverse(head);//中序遍历整个数组 printf("\n请按任意键返回主菜单..."); break; case 3:printf("\n请输入要查找哪个成员的祖先：\n"); scanf("%s",cname); getchar(); FindAncestry(head,cname,0); printf("\n请按任意键返回主菜单..."); break; case 4: exit(0); } getchar(); } } void ScanLevel(BTree *bt) /*按层次顺序遍历二叉家族树 */ { int front=0,rear=0; /* 初始化队列的头、尾指针 */ if(bt!=NULL) { rear++; q[rear]=bt; /* 将bt所指向的结点入队 */ } while(front!=rear) /* 队列非空 */ { front++; bt=q[front]; /* 队头结点出队 */ printf (" %s",bt->name); /* 输出该结点的数据 */ if(bt->lchild!=NULL) { rear++; q[rear]=bt->lchild; /* 将左孩子结点入队 */ } if(bt->rchild!=NULL) {rear++; q[rear]=bt->rchild; /* 将右孩子结点入队 */ } } } int FindAncestry(BTree *bt,char *ch,int flag) { int flag1=0,flag2=0; int cond; if(flag==0&&strcmp(bt->name,ch)==0) { printf("这个人是最大的祖先!!!\n"); return 0; } flag=1; if(bt==NULL||(bt->lchild==NULL&&bt->rchild==NULL)) return 0; cond=(bt->lchild!=NULL)&&(strcmp(bt->lchild->name,ch)==0); cond=cond||((bt->rchild!=NULL)&&(strcmp(bt->rchild->name,ch)==0)); if(cond) { printf("%s，",bt->name); return 1; } else { flag1=FindAncestry(bt->lchild,ch,flag); flag2=FindAncestry(bt->rchild,ch,flag); if(flag1||flag2) { printf("%s，",bt->name); return 1; } else return 0; } } void Precreat(BTree *bt) { char ch1[10]; scanf("%s",ch1); if(strcmp(ch1,"\$")) { bt=NULL; } else { bt=(BTree*)malloc(sizeof(BTree)); strcpy(bt->name,ch1); Precreat(bt->lchild); Precreat(bt->rchild); } printf("建立完成"); return; } void InorderTraverse(BTree *bt) //中序遍历整个数组 { if(bt) { InorderTraverse(bt->lchild); printf(" %s",bt->name); InorderTraverse(bt->rchild); } } 写precreat函数，要求\$为结束符@为空
java编写查找二叉树某个结点的父节点的算法

//从终端输入一个整数序列，构建一棵允许具有重复结点的二叉排序树（左子树元素小，右子树不小）： //(1) 使用依次插入元素的方法（InsertBST）构建二叉排序树； //(2) 分别写出二叉树的前序、中序、后序遍历递归算法； //(3) 写出前序遍历序列的非递归算法（使用以前写好的堆栈代码）； //(4) 使用递归算法求该二叉树中叶子结点和非叶子结点的个数； //(5) 使用递归算法求该二叉树的高度； //(6) 层次遍历该二叉树（使用以前写好的队列代码）； //(7) 从终端输入一个整数，查找这个整数是否在该二叉树中，成功返回true，否则false（要求使用非递归）； //(8) 销毁这个二叉树，释放其中的每一个结点；
C#中有没有二叉树？C#里泛型实现二叉树遍历，求代码的实现
C#中有没有二叉树？C#里泛型实现二叉树遍历，求代码的实现
C语言数据结构二叉树-目录树的基本操作求解？
**_数据结构作业题_** **计算机目录树的基本操作（设计性实验）** [问题描述] 对计算机中的目录树实现：建立目录、修改目录结构、查询和删除等操作。 [基本要求] (1)按二叉链表的存储方式存储计算机中的目录树； (2)实现目录树的建立和遍历及插入结点和删除结点操作。 [测试数据] 由读者依据软件工程的测试技术自己确定。注意测试边界数据。 [实现提示] (1)根据树与二叉树的对应关系，对树的操作最终以对二叉树的操作实现； (2)查询操作可以实现是否存在某目录或查询指定目录的父目录或子目录。 [思考题] 如果引入Windows 系统中的快捷方式，该如何处理？
C++二叉树应用问题求助

《奇巧淫技》系列-python！！每天早上八点自动发送天气预报邮件到QQ邮箱

8年经验面试官详解 Java 面试秘诀
作者 | 胡书敏 责编 | 刘静 出品 | CSDN（ID：CSDNnews） 本人目前在一家知名外企担任架构师，而且最近八年来，在多家外企和互联网公司担任Java技术面试官，前后累计面试了有两三百位候选人。在本文里，就将结合本人的面试经验，针对Java初学者、Java初级开发和Java开发，给出若干准备简历和准备面试的建议。   Java程序员准备和投递简历的实

MyBatis研习录(01)——MyBatis概述与入门
C语言自学完备手册(33篇) Android多分辨率适配框架 JavaWeb核心技术系列教程 HTML5前端开发实战系列教程 MySQL数据库实操教程(35篇图文版) 推翻自己和过往——自定义View系列教程(10篇) 走出思维困境，踏上精进之路——Android开发进阶精华录 讲给Android程序员看的前端系列教程(40集免费视频教程+源码) 版权声明 本文原创作者：谷哥的小弟 作者博客

Python爬虫爬取淘宝，京东商品信息

Java工作4年来应聘要16K最后没要,细节如下。。。

Python爬虫精简步骤1 获取数据

Python绘图，圣诞树，花，爱心 | Turtle篇
1.画圣诞树 import turtle screen = turtle.Screen() screen.setup(800,600) circle = turtle.Turtle() circle.shape('circle') circle.color('red') circle.speed('fastest') circle.up() square = turtle.Turtle()

CPU对每个程序员来说，是个既熟悉又陌生的东西？ 如果你只知道CPU是中央处理器的话，那可能对你并没有什么用，那么作为程序员的我们，必须要搞懂的就是CPU这家伙是如何运行的，尤其要搞懂它里面的寄存器是怎么一回事，因为这将让你从底层明白程序的运行机制。 随我一起，来好好认识下CPU这货吧 把CPU掰开来看 对于CPU来说，我们首先就要搞明白它是怎么回事，也就是它的内部构造，当然，CPU那么牛的一个东

2020年1月17日，国家统计局发布了2019年国民经济报告，报告中指出我国人口突破14亿。 猪哥的朋友圈被14亿人口刷屏，但是很多人并没有看到我国复杂的人口问题：老龄化、男女比例失衡、生育率下降、人口红利下降等。 今天我们就来分析一下我们国家的人口数据吧！ 更多有趣分析教程，扫描下方二维码关注vx公号「裸睡的猪」 即可查看！ 一、背景 1.人口突破14亿 2020年1月17日，国家统计局发布
web前端javascript+jquery知识点总结
Javascript javascript 在前端网页中占有非常重要的地位，可以用于验证表单，制作特效等功能，它是一种描述语言，也是一种基于对象（Object）和事件驱动并具有安全性的脚本语言 ，语法同java类似，是一种解释性语言，边执行边解释。 JavaScript的组成： ECMAScipt 用于描述: 语法，变量和数据类型，运算符，逻辑控制语句，关键字保留字，对象。 浏览器对象模型（Br
Python实战：抓肺炎疫情实时数据，画2019-nCoV疫情地图

Python：爬取疫情每日数据

B 站上有哪些很好的学习资源?

Web播放器解决了在手机浏览器和PC浏览器上播放音视频数据的问题，让视音频内容可以不依赖用户安装App，就能进行播放以及在社交平台进行传播。在视频业务大数据平台中，播放数据的统计分析非常重要，所以Web播放器在使用过程中，需要对其内部的数据进行收集并上报至服务端，此时，就需要对发生在其内部的一些播放行为进行事件监听。 那么Web播放器事件监听是怎么实现的呢？ 01 监听事件明细表 名
3万字总结，Mysql优化之精髓

Python新型冠状病毒疫情数据自动爬取+统计+发送报告+数据屏幕（三）发送篇

1. 传统事件绑定和符合W3C标准的事件绑定有什么区别？ 传统事件绑定 &lt;div onclick=""&gt;123&lt;/div&gt; div1.onclick = function(){}; &lt;button onmouseover=""&gt;&lt;/button&gt; 注意： 如果给同一个元素绑定了两次或多次相同类型的事件，那么后面的绑定会覆盖前面的绑定 （不支持DOM事...