Skip to content

Commit 78e18ab

Browse files
authored
Create README.md
1 parent 0e0770b commit 78e18ab

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<h1 align='center'>BINARY - SEARCH TREE - DATA STRUCTURE - PROBLEMS</h1>
2+
3+
<p align='center'>
4+
A <b>Binary Search Tree (BST)</b> is a node-based binary tree data structure where each node follows the property:
5+
- The left subtree contains nodes with values less than the node’s value.
6+
- The right subtree contains nodes with values greater than the node’s value.
7+
BSTs provide efficient searching, insertion, and deletion operations, making them integral to various computer science applications.
8+
</p>
9+
10+
### Key Concepts:
11+
- **Root Node**: The topmost node in the BST.
12+
- **Leaf Nodes**: Nodes without children.
13+
- **Subtree**: A tree formed by any node and its descendants.
14+
- **Balanced BST**: A BST where the height difference between the left and right subtrees is at most 1.
15+
- **Traversals**: BSTs are traversed using Inorder, Preorder, or Postorder traversals.
16+
17+
### Applications:
18+
1. **Search Operations**: Efficiently search for a value in \(O(\log n)\) time in balanced BSTs.
19+
2. **Range Queries**: Retrieve all keys within a given range.
20+
3. **Inorder Traversal**: Retrieves nodes in sorted order.
21+
4. **Dynamic Sets**: Store and manage dynamic datasets.
22+
23+
24+
### Repository Content
25+
<p>
26+
<img src="https://img.shields.io/badge/problems%20count-08-orange?logo=leetcode" alt="LeetCode">
27+
<img src="https://img.shields.io/badge/problems%20count-10-darkgreen?logo=geeksforGeeks" alt="GeeksforGeeks">
28+
<img src="https://img.shields.io/badge/total%20problems%20count-19-blue" alt="Problem Count">
29+
</p>
30+
31+
| **No** | **Problem Name** | **Description** | **LeetCode** | **GFG** |
32+
| ------ | -------------------------------------------------------------- | --------------------------------------------------- | ---------------------------------------------------- | ------------------------------------------------------- |
33+
| 01 | [Example](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/18%20-%20Binary%20Search%20Tree%20Data%20Structure%20Problems/01%20-%20Example) | Basic examples of BST operations. | Non | Non |
34+
| 02 | [Search a Node in BST](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/18%20-%20Binary%20Search%20Tree%20Data%20Structure%20Problems/02%20-%20Search%20a%20Node%20in%20BST) | Check if a node exists in a BST. | Non | [Link](https://www.geeksforgeeks.org/problems/search-a-node-in-bst/1?itm_source=geeksforgeeks&itm_medium=article&itm_campaign=practice_card) |
35+
| 03 | [Search in a Binary Search Tree](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/18%20-%20Binary%20Search%20Tree%20Data%20Structure%20Problems/03%20-%20Search%20in%20a%20Binary%20Search%20Tree) | Retrieve a node in a BST based on value. | [Link](https://leetcode.com/problems/search-in-a-binary-search-tree/description/) | Non |
36+
| 04 | [Validate Binary Search Tree](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/18%20-%20Binary%20Search%20Tree%20Data%20Structure%20Problems/04%20-%20Validate%20Binary%20Search%20Tree) | Determine if a tree is a valid BST. | [Link](https://leetcode.com/problems/validate-binary-search-tree/) | Non |
37+
| 05 | [Check for BST](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/18%20-%20Binary%20Search%20Tree%20Data%20Structure%20Problems/05%20-%20Check%20for%20BST) | Validate a tree as a BST. | Non | [Link](https://www.geeksforgeeks.org/problems/check-for-bst/1?itm_source=geeksforgeeks&itm_medium=article&itm_campaign=practice_card) |
38+
| 06 | [Kth Smallest Element in a BST](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/18%20-%20Binary%20Search%20Tree%20Data%20Structure%20Problems/06%20-%20Kth%20Smallest%20Element%20in%20a%20BST) | Find the kth smallest element in a BST. | [Link](https://leetcode.com/problems/kth-smallest-element-in-a-bst/) | Non |
39+
| 07 | [K-th Smallest Element in BST](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/18%20-%20Binary%20Search%20Tree%20Data%20Structure%20Problems/07%20-%20K-th%20Smallest%20Element%20in%20BST) | Another approach to find kth smallest. | Non | [Link](https://www.geeksforgeeks.org/problems/find-k-th-smallest-element-in-bst/1) |
40+
| 08 | [Kth Largest Element in BST](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/18%20-%20Binary%20Search%20Tree%20Data%20Structure%20Problems/08%20-%20Kth%20Largest%20Element%20in%20BST) | Retrieve the kth largest element in BST. | Non | [Link](https://www.geeksforgeeks.org/problems/kth-largest-element-in-bst/1) |
41+
| 09 | [Predecessor and Successor](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/18%20-%20Binary%20Search%20Tree%20Data%20Structure%20Problems/09%20-%20Predecessor%20and%20Successor) | Find in-order predecessor and successor. | Non | [Link](https://www.geeksforgeeks.org/problems/predecessor-and-successor/1) |
42+
| 10 | [Lowest Common Ancestor of a BST](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/18%20-%20Binary%20Search%20Tree%20Data%20Structure%20Problems/10%20-%20Lowest%20Common%20Ancestor%20of%20a%20BST) | Identify LCA of two nodes in BST. | [Link](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-search-tree/) | Non |
43+
| 11 | [Lowest Common Ancestor in a BST](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/18%20-%20Binary%20Search%20Tree%20Data%20Structure%20Problems/11%20-%20Lowest%20Common%20Ancestor%20in%20a%20BST) | Alternative solution for finding LCA in a BST. | Non | [Link](https://www.geeksforgeeks.org/problems/lowest-common-ancestor-in-a-bst/1?itm_source=geeksforgeeks&itm_medium=article&itm_campaign=practice_card) |
44+
| 12 | [Two Sum IV - Input is BST](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/18%20-%20Binary%20Search%20Tree%20Data%20Structure%20Problems/12%20-%20Two%20Sum%20IV%20-%20Input%20is%20BST) | Check if two numbers in BST sum up to a target. | [Link](https://leetcode.com/problems/two-sum-iv-input-is-a-bst/) | Non |
45+
| 13 | [Flatten BST to Sorted List](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/18%20-%20Binary%20Search%20Tree%20Data%20Structure%20Problems/13%20-%20Flatten%20BST%20to%20Sorted%20List) | Convert BST to a sorted linked list. | Non | [Link](https://www.geeksforgeeks.org/problems/flatten-bst-to-sorted-list--111950/0) |
46+
| 14 | [Normal BST to Balanced BST](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/18%20-%20Binary%20Search%20Tree%20Data%20Structure%20Problems/14%20-%20Normal%20BST%20to%20Balanced%20BST) | Convert an unbalanced BST to a balanced BST. | Non | [Link](https://www.geeksforgeeks.org/problems/normal-bst-to-balanced-bst/1) |
47+
| 15 | [Balance a Binary Search Tree](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/18%20-%20Binary%20Search%20Tree%20Data%20Structure%20Problems/15%20-%20Balance%20a%20Binary%20Search%20Tree) | Create a balanced BST from a normal BST. | [Link](https://leetcode.com/problems/balance-a-binary-search-tree/) | Non |
48+
| 16 | [Construct Binary Search Tree from Pre-order Traversal](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/18%20-%20Binary%20Search%20Tree%20Data%20Structure%20Problems/16%20-%20Construct%20Binary%20Search%20Tree%20from%20Pre-order%20Traversal) | Build a BST from a pre-order traversal array. | [Link](https://leetcode.com/problems/construct-binary-search-tree-from-preorder-traversal/description/) | Non |
49+
| 17 | [Merge Two BST's](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/18%20-%20Binary%20Search%20Tree%20Data%20Structure%20Problems/17%20-%20Merge%20Two%20BST's) | Merge two binary search trees into one. | Non | [Link](https://www.geeksforgeeks.org/problems/merge-two-bst-s/1) |
50+
| 18 | [Largest BST](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/18%20-%20Binary%20Search%20Tree%20Data%20Structure%20Problems/18%20-%20Largest%20BST) | Find the largest BST subtree in a binary tree. | Non | [Link](https://www.geeksforgeeks.org/problems/largest-bst/1) |
51+
| 19 | [Maximum Sum BST in Binary Tree](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/18%20-%20Binary%20Search%20Tree%20Data%20Structure%20Problems/19%20-%20Maximum%20Sum%20BST%20in%20Binary%20Tree) | Determine the maximum sum of a BST in a binary tree.| [Link](https://leetcode.com/problems/maximum-sum-bst-in-binary-tree/) | Non |
52+
53+
---
54+
Happy Coding 😊

0 commit comments

Comments
 (0)