函数题:Print the right subtree of X in BST
Given a binary search tree T, you are supposed to output all the elements in the right subtree of X, in *decreasing order*.
### Format of functions:
c
void print_right_subtree( Tree T, int X );
where Tree is defined as:
c
typedef struct TreeNode *Tree;
struct TreeNode {
int element;
Tree left;
Tree right;
};
### Sample program of judge:
c
#include <stdio.h>
#include <stdlib.h>
typedef struct TreeNode *Tree;
struct TreeNode {
int element;
Tree left;
Tree right;
};
Tree build_tree(); /* details omitted */
void print_right_subtree(Tree T, int X);
int main()
{
Tree T;
int X;
T = build_tree();
scanf("%d", &X);
print_right_subtree(T, X);
return 0;
}
/* Your function(s) will be put here */
### Sample Input
in
7
90 80 91 55 85 81 92
80
### Sample Output:

<br/><br/>
For the sample above, your program should output:
out
85 81 end
For an empy tree, simply output:
empty tree
In case X is not found in T, output:
x not found
where the letter "x" is NOT the value of X.
答案:若无答案欢迎评论
### Format of functions:
c
void print_right_subtree( Tree T, int X );
where Tree is defined as:
c
typedef struct TreeNode *Tree;
struct TreeNode {
int element;
Tree left;
Tree right;
};
### Sample program of judge:
c
#include <stdio.h>
#include <stdlib.h>
typedef struct TreeNode *Tree;
struct TreeNode {
int element;
Tree left;
Tree right;
};
Tree build_tree(); /* details omitted */
void print_right_subtree(Tree T, int X);
int main()
{
Tree T;
int X;
T = build_tree();
scanf("%d", &X);
print_right_subtree(T, X);
return 0;
}
/* Your function(s) will be put here */
### Sample Input
in
7
90 80 91 55 85 81 92
80
### Sample Output:

<br/><br/>
For the sample above, your program should output:
out
85 81 end
For an empy tree, simply output:
empty tree
In case X is not found in T, output:
x not found
where the letter "x" is NOT the value of X.
答案:若无答案欢迎评论