Skip to content

PRO TIP Block youtube.com at the DNS level — Pi-hole, NextDNS or your hosts file — but allow youtube-nocookie.com and i.ytimg.com. These tutorials keep playing; the rabbit hole does not.

Learning without distractions

DSA in Python Course – Predecessor and Successor in BST | GFG Practice | Part 179 [Hindi]

1.3K views on YouTube

📘 Welcome to Part 179 of Code & Debug’s DSA in Python Course!

In this video, we solve the essential problem: Predecessor and Successor from GeeksforGeeks. We’ll implement an efficient iterative solution to find the in-order predecessor (largest node smaller than the key) and successor (smallest node larger than the key) in a Binary Search Tree without performing full inorder traversal.

This problem is crucial for understanding BST navigation and is commonly asked in interviews to test your ability to find bounds without extra space.

👨‍🏫 What’s covered in this video:
✅ Understanding the problem statement from GFG
✅ Logic for finding predecessor (largest smaller node)
✅ Logic for finding successor (smallest larger node)
✅ Step-by-step iterative traversal approach
✅ Handling cases where predecessor or successor doesn’t exist
✅ Complete Python code walkthrough with helper functions
✅ Time and Space Complexity analysis (O(h) time, O(1) space)
✅ Interview tips and edge cases

By the end of this session, you’ll be able to confidently find predecessors and successors in BSTs and apply this knowledge to similar problems!

🔗 GFG Problem – Predecessor and Successor:
https://www.geeksforgeeks.org/problems/predecessor-and-successor/1

📄 Full Playlist Sheet (All Questions in Order):
https://docs.google.com/spreadsheets/d/1AWE15Fy3wD2iqu2vjK_R7cCiuvSsjYQclcdZmHpF66o/edit?usp=sharing

🎓 Enroll in the FREE Python DSA Course:
https://codeanddebug.in/course/master-dsa-with-leetcode

🚀 Advance Python DSA for FAANG (Zero to Hero Course):
https://codeanddebug.in/course/zero-to-hero-python-dsa

Stay focused and keep coding with Code & Debug.
Like | Share | Subscribe | Hit the 🔔

#PredecessorSuccessor #BST #BinarySearchTree #PythonDSA #GFGPractice #TreeProblems #CodeAndDebug #Part179 #DataStructures #DSAforInterviews