Delete Node in binary search tree
Автор: MostOptimal
Загружено: 2026-01-15
Просмотров: 1
📌 Delete Node in a Binary Search Tree | LeetCode Explained
In this video, we solve the Delete Node in a Binary Search Tree problem from LeetCode.
Given the root of a BST and a key, the task is to delete the node with that key while maintaining BST properties.
🔍 Problem Overview
Input: Root of a Binary Search Tree and a key to delete
Output: Root of the updated BST
The BST structure must remain valid after deletion
💡 Approach Explained
We handle three possible cases when deleting a node:
Node has no child (leaf node) → simply remove it
Node has one child → replace the node with its child
Node has two children →
Find the inorder successor (smallest value in right subtree)
Replace the node’s value with the successor
Delete the successor node
⏱️ Time & Space Complexity
Time Complexity: O(h), where h is the height of the tree
Space Complexity: O(h) due to recursion stack
✅ Key Concepts Covered
Binary Search Tree properties
Inorder successor
Recursive tree modification
Handling edge cases
🎯 Why Watch This Video?
✔ Clear explanation of all deletion cases
✔ Step-by-step logic
✔ Clean and interview-ready code
✔ Common BST interview problem
#LeetCode #BinarySearchTree #DeleteNode #DSA #CodingInterview #Java #BST
Доступные форматы для скачивания:
Скачать видео mp4
-
Информация по загрузке: