int findceil(node* root, int key)
{
int ceil=-1;
while(root)
{
if(root->data==key)
{
ceil=key;
return ceil;
}
if(root->data<key)
{
root=root->right;
}
else
{
ceil=root->data;
root=root->left;
}
}
return ceil;
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter