Find Predecessor And Successor Of Key In BST

preview_player
Показать описание
JOIN ME:

Time Lines
=========
0:05 Introduction
1:06 Approach
4:25 Example Code Explanation

In this video we will learn how to find the predecessor and successor of a binary search tree (BST)
The method what i have explained here is best and the time complexity is O(h) where h is height of a BST.

BST means sorted so the simple approach could be that we can traverse inorder and store those elements in array and then find the required number, but this will be very time and space consuming if BST is very large.
So i have explained a recursive approach to solve this problem and that is so best that if we can't find the given key then also it will print the approximate and print the predecessor and successor.

#bst #binarysearchtree #dsa #algorithm #interview
Рекомендации по теме
Комментарии
Автор

awsome explanation sir tysm for the video

Raj