• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests
December 02, 2023 |790 Views
PROBLEM OF THE DAY: 01/12/2023 | Check whether BST contains Dead End
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 also build up problem-solving skills.

In this problem, we are given, a Binary Search Tree that contains unique positive integer values greater than 0. The task is to complete the function isDeadEnd which returns true if the BST contains a dead end else returns false. Here Dead End means a leaf node, at which no other node can be inserted.

Example :

Input :   
              8
            /   \ 
          5      9
        /  \     
       2    7 
      /
     1     
         
Output : 
Yes

Explanation : 
Node 1 is a Dead End in the given BST.

Give the problem a try before going through the video. All the best!!!
Problem Link: https://practice.geeksforgeeks.org/problems/check-whether-bst-contains-dead-end/1
Solution IDE Link: https://ide.geeksforgeeks.org/online-cpp-compiler/12ee2485-7dbc-4480-a359-fd0797b660e6