#include <stdio.h>
/*Макросы для сравнения Equal, Lower Than, Greater Than*/
#define CMP_EQ(a, b) ((a) == (b))
#define CMP_LT(a, b) ((a) < (b))
#define CMP_GT(a, b) ((a) > (b))
struct node{
int data;
struct node *left;
struct node *right;
struct node *parent;
};
/*Процелура в псевдокоде*/
/*
Tree_Search(x, k)
while x != NIL and k != key[x] do
if k < key[x]
then x <- left[x]
else x <- right[x]
return x
*/
/*Реализация на си*/
struct node * TreeSearch(struct node *root, int k){
while(root != NULL && root->data != k){
if(k < root->data)
root = root->left;
else
root = root->right;
}
return root;
}
int main(void) {
// your code goes here
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CgovKtCc0LDQutGA0L7RgdGLINC00LvRjyDRgdGA0LDQstC90LXQvdC40Y8gRXF1YWwsIExvd2VyIFRoYW4sIEdyZWF0ZXIgVGhhbiovCiNkZWZpbmUgQ01QX0VRKGEsIGIpICgoYSkgPT0gKGIpKQojZGVmaW5lIENNUF9MVChhLCBiKSAoKGEpIDwgKGIpKQojZGVmaW5lIENNUF9HVChhLCBiKSAoKGEpID4gKGIpKQoKc3RydWN0IG5vZGV7CglpbnQgZGF0YTsKCXN0cnVjdCBub2RlICpsZWZ0OwoJc3RydWN0IG5vZGUgKnJpZ2h0OwoJc3RydWN0IG5vZGUgKnBhcmVudDsKfTsKCi8q0J/RgNC+0YbQtdC70YPRgNCwINCyINC/0YHQtdCy0LTQvtC60L7QtNC1Ki8KLyoKVHJlZV9TZWFyY2goeCwgaykKCXdoaWxlIHggIT0gTklMIGFuZCBrICE9IGtleVt4XSBkbwoJCWlmIGsgPCBrZXlbeF0KCQkJdGhlbiB4IDwtIGxlZnRbeF0KCQkJZWxzZSB4IDwtIHJpZ2h0W3hdCglyZXR1cm4geAoqLwoKLyrQoNC10LDQu9C40LfQsNGG0LjRjyDQvdCwINGB0LgqLwpzdHJ1Y3Qgbm9kZSAqIFRyZWVTZWFyY2goc3RydWN0IG5vZGUgKnJvb3QsIGludCBrKXsKCXdoaWxlKHJvb3QgIT0gTlVMTCAmJiByb290LT5kYXRhICE9IGspewoJCWlmKGsgPCByb290LT5kYXRhKQoJCQlyb290ID0gcm9vdC0+bGVmdDsKCQllbHNlCgkJCXJvb3QgPSByb290LT5yaWdodDsKCX0KCXJldHVybiByb290Owp9CgppbnQgbWFpbih2b2lkKSB7CgkvLyB5b3VyIGNvZGUgZ29lcyBoZXJlCglyZXR1cm4gMDsKfQo=