6-20 No Less Than X in BST(20 分)
You are supposed to output, in decreasing order, all the elements no less than X in a binary search tree T.
Format of function:
void Print_NLT( Tree T, int X );
where Tree is defined as the following:
typedef struct TreeNode *Tree;
struct TreeNode {
int Element;
Tree Left;
Tree Right;
};
The function is supposed to use Output(X) to print X.
Sample program of judge:
#include <stdio.h>
#include <stdlib.h>
typedef struct TreeNode *Tree;
struct TreeNode {
int Element;
Tree Left;
Tree Right;
};
Tree BuildTree(); /* details omitted */
void Output( int X ); /* details omitted */
void Print_NLT( Tree T, int X );
int main()
{
Tree T;
int X;
T = BuildTree();
scanf("%d", &X);
Print_NLT( T, X );
printf("End\n");
return 0;
}
/* Your function will be put here */
Sample Output 1 (for the tree shown in Figure 1):
92 91 90 85 81 80 End
Figure 1
Sample Output 2 (for the tree shown in Figure 2):
End
Figure 2
void Print_NLT( Tree T, int X )
{
if(T == NULL)return;
Print_NLT(T -> Right,X);
if(T -> Element >= X)printf("%d ",T -> Element);
Print_NLT(T -> Left,X);
}
6-20 No Less Than X in BST(20 分)的更多相关文章
- 2016年11月20日 星期日 --出埃及记 Exodus 20:11
2016年11月20日 星期日 --出埃及记 Exodus 20:11 For in six days the LORD made the heavens and the earth, the sea ...
- 【福利】FL Studio 20 汉化补丁包 _FL Studio 20 汉化包下载
我这两天在网上搜索FL Studio 20汉化包,找了半天也没有找到真正的汉化包,不过好在功夫不负有心人,让我找到了一个不错的FL Studio 20汉化网站,里面提供了FL Studio 20汉化包 ...
- C8051逆向电阻屏:头儿拍脑袋说电阻屏IC好赚钱3块钱成本能卖20几块。,一个月不分昼夜逆向成功后头儿说电阻屏已经被市场淘汰请放弃治疗。
参考: 书籍,<圈圈教你玩USB> C8051F单片机快速入门:http://www.waveshare.net/Left_Column/C8051F_Application_Notes ...
- 【PAT甲级】1115 Counting Nodes in a BST (30分)(二叉查找树)
题意: 输入一个正整数N(<=1000),接着输入N个整数([-1000,1000]),依次插入一棵初始为空的二叉排序树.输出最底层和最底层上一层的结点个数之和,例如x+y=x+y. AAAAA ...
- 得到一个a(10)到b(20)的随机数。包括10和20
- PAT_A1115#Counting Nodes in a BST
Source: PAT A1115 Counting Nodes in a BST (30 分) Description: A Binary Search Tree (BST) is recursiv ...
- [MySQL Reference Manual] 20 分区
20 分区 20 分区 20.1 MySQL的分区概述 20.2 分区类型 20.2.1 RANGE分区 20.2.2 LIST分区 20.2.3 COLUMNS分区 20.2.3.1 RANGE C ...
- [转]MIDI常识20条
原文链接:http://www.midifan.com/modulearticle-detailview-488.htm Keyboard杂志老资格编辑Jim Aikin在纪念MIDI诞生20的时候发 ...
- ITK 3.20.1 VS2010 Configuration 配置
Download ITK 3.20.1 Download VS2010 Download CMake 3.2.0 I assume you've already installed VS2010 an ...
- 《javascript高级程序设计》 第20章 JSON
20.1 语法 20.1.1 简单值 20.1.2 对象 20.1.3 数组 20.2 解析与序列化 20.2.1 JSON 对象 20.2.2 序列化选项 20.2.3 解析选项 JSON 对象有两 ...
随机推荐
- 团队 作业6--展示(alpha阶段)
团队作业6--展示博客(alpha阶段) 一.团队信息 团队码云地址: https://gitee.com/kezhiqing/soft_team_blog 成员介绍: 个人博客地址 团队成员 个人博 ...
- linux wa%过高,iostat查看io状况
命令总结: 1. top/vmstat 发现 wa%过高,vmstat b >1: 参考文章: 1. 关于Linux系统指令 top 之 %wa 占用高,用`iostat`探个究竟 最近测试一项 ...
- OpenCV/OpenCL/OpenGL区别
OpenCV/OpenCL/OpenGL区别: OpenGL(全写Open Graphics Library)是个定义了一个跨编程语言.跨平台的应用程序接口(API)的规格,它用于生成二维.三维图像. ...
- FZU 1901 Period II(KMP中的next)题解
题意:给你一串字符串,问你前后缀相同情况有几种,并输出后缀位置(?这里一直没看懂length是什么,但是这样理解答案也对,然后还要加上本身长度) 思路:这里好好讲讲next的用法.我们都知道next代 ...
- POJ 2240 Arbitrage(判正环)
http://poj.org/problem?id=2240 题意:货币兑换,判断最否是否能获利. 思路:又是货币兑换题,Belloman-ford和floyd算法都可以的. #include< ...
- Binary Tree Level Order Traversal,层序遍历二叉树,每层作为list,最后返回List<list>
问题描述: Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to ...
- Java线程池Executor使用
合理利用线程池能够带来三个好处.第一:降低资源消耗.通过重复利用已创建的线程降低线程创建和销毁造成的消耗.第二:减少系统对于,外部 服务的响应时间的等待.第三:提高线程的可管理性.线程是稀缺资源,如果 ...
- Spring IOC 源码简单分析 02 - Bean Reference
### 准备 ## 目标 了解 bean reference 装配的流程 ##测试代码 gordon.study.spring.ioc.IOC02_BeanReference.java ioc02 ...
- Vue.js的类Class 与属性 Style如何绑定
Vue.js的类Class 与属性 Style如何绑定 一.总结 一句话总结:数据绑定一个常见需求是操作元素的 class 列表和它的内联样式.因为它们都是属性,我们可以用 v-bind 处理它们:我 ...
- Java中HashMap的put与get方法原理
直接上代码 注: 代码来自于 Java 9 put方法 public V put(K key, V value) { return putVal(hash(key), key, value, fals ...