• Courses
  • Tutorials
  • DSA
  • Data Science
  • Web Tech
August 09, 2024 |90 Views

SDE Sheet - Ceil in BST

Description
Discussion

This video is part of the Binary Search Tree section under GFG SDE Sheet.

Given a BST and a number X, find Ceil of X.
Note: Ceil(X) is a number that is either equal to X or is immediately greater than X.

If Ceil could not be found, return -1.

Example 1:

Input:      5     /   \    1     7     \      2       \        3 X = 3 Output: 3 Explanation: We find 3 in BST, so ceil of 3 is 3.

Try it out before watching the implementation of the problem in the video. We recommend watching the video, even if you can solve the problem. You may discover something new. All the best!!!

Do check out:-
Problem: https://www.geeksforgeeks.org/problems/implementing-ceil-in-bst/1
SDE Sheet Link: https://www.geeksforgeeks.org/sde-sheet-a-complete-guide-for-sde-preparation/
Article Link: https://www.geeksforgeeks.org/floor-and-ceil-from-a-bst/