3

PROBLEM OF THE DAY: 13/10/2023 | Floor in BST

 11 months ago
source link: https://www.geeksforgeeks.org/videos/problem-of-the-day-13102023-floor-in-bst/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

PROBLEM OF THE DAY: 13/10/2023

October 14, 2023 |730 Views
PROBLEM OF THE DAY: 13/10/2023 | Floor in BST
Problem of the Day, Data Structures and Algorithms, binary-search-tree
 Save  Share  2 Likes
Description
Discussion

Welcome to the daily solving of our PROBLEM OF THE DAY with Karan Mashru. We will discuss the entire problem step-by-step and work towards developing an optimized solution. This will not only help you brush up on your concepts of Binary Search Tree but will also help you build up problem-solving skills.

In this problem, we are given, a BST(Binary Search Tree) with n number of nodes and value x. Your task is to find the greatest value node of the BST which is smaller than or equal to x.
Note: when x is smaller than the smallest node of BST then returns -1.

Example:

Input:
n = 7               2
                    \
                     81
                   /     \
                42       87
                  \       \
                   66      90
                  /
                45
x = 87

Output:
87

Explanation:
87 is present in tree so floor will be 87.

Give the problem a try before going through the video. All the best!!!

Problem Link: https://practice.geeksforgeeks.org/problems/floor-in-bst/1
Solution IDE Link: https://ide.geeksforgeeks.org/online-cpp-compiler/4d4ce38f-e871-43ac-962a-a1429a3ab65b

Read More

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK