Skip to content

Commit 0e0770b

Browse files
authored
Create README.md
1 parent 74e8bf8 commit 0e0770b

File tree

1 file changed

+79
-0
lines changed
  • 17 - Binary Tree Data Structure Problems

1 file changed

+79
-0
lines changed
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
<h1 align='center'>BINARY - TREE - DATA STRUCTURE - PROBLEMS</h1>
2+
3+
<p align='center'>A <b>Binary Tree</b> is a data structure in which each node has at most two children, referred to as the left child and the right child. It is one of the most fundamental structures in computer science, widely used in algorithms, data storage, and computational problems. Binary trees are particularly useful in searching, sorting, and structuring data in an efficient way.
4+
</p>
5+
6+
### Key Concepts:
7+
- **Root Node**: The topmost node in the tree.
8+
- **Leaf Nodes**: Nodes that have no children.
9+
- **Parent and Child Nodes**: A node connected to a child node is the parent of that child.
10+
- **Subtree**: A tree formed by any node and its descendants.
11+
- **Height of Tree**: The number of edges in the longest path from the root node to a leaf.
12+
- **Depth of Tree**: The number of edges from the root to a specific node.
13+
14+
### Types of Binary Trees:
15+
1. **Full Binary Tree**: Every node has either 0 or 2 children.
16+
2. **Perfect Binary Tree**: All internal nodes have exactly 2 children and all leaf nodes are at the same level.
17+
3. **Complete Binary Tree**: Every level, except possibly the last, is completely filled, and all nodes are as far left as possible.
18+
4. **Balanced Binary Tree**: The height difference between the left and right subtrees of any node is at most 1.
19+
20+
### Applications:
21+
- **Search Operations**: Binary Search Trees (BSTs) allow fast searching, insertion, and deletion operations.
22+
- **Traversal Algorithms**: Binary trees are frequently traversed using Inorder, Preorder, and Postorder traversals.
23+
- **Heap Structures**: Binary Heaps are a complete binary tree used for efficient priority queues.
24+
- **Expression Parsing**: Binary trees are used to represent mathematical expressions for evaluation.
25+
26+
### Repository Content
27+
<p>
28+
<img src="https://img.shields.io/badge/problems%20count-11-orange?logo=leetcode" alt="LeetCode">
29+
<img src="https://img.shields.io/badge/problems%20count-21-darkgreen?logo=geeksforGeeks" alt="GeeksforGeeks">
30+
<img src="https://img.shields.io/badge/total%20problems%20count-35-blue" alt="Problem Count">
31+
</p>
32+
33+
Here is the table with the 20 problems listed from your Binary Tree Data Structure Problems folder, with the correct links to the respective folders and available LeetCode/GFG links:
34+
35+
| **No** | **Problem Name** | **Description** | **LeetCode** | **GFG** |
36+
| ------ | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------ | ------- |
37+
| 01 | [Example](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/17%20-%20Binary%20Tree%20Data%20Structure%20Problems/01%20-%20Example) | Basic examples of binary tree operations and traversal. | Non | Non |
38+
| 02 | [Height of Binary Tree](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/17%20-%20Binary%20Tree%20Data%20Structure%20Problems/02%20-%20Height%20of%20Binary%20Tree) | Find the height of a binary tree. | Non | [Link](https://www.geeksforgeeks.org/problems/height-of-binary-tree/1?itm_source=geeksforgeeks&itm_medium=article&itm_campaign=practice_card) |
39+
| 03 | [Maximum Depth of Binary Tree](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/17%20-%20Binary%20Tree%20Data%20Structure%20Problems/03%20-%20Maximum%20Depth%20of%20Binary%20Tree) | Find the maximum depth of a binary tree. | [Link](https://leetcode.com/problems/maximum-depth-of-binary-tree/) | Non |
40+
| 04 | [Minimum Depth of Binary Tree](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/17%20-%20Binary%20Tree%20Data%20Structure%20Problems/04%20-%20Minimum%20Depth%20of%20Binary%20Tree) | Find the minimum depth of a binary tree. | [Link](https://leetcode.com/problems/minimum-depth-of-binary-tree/) | Non |
41+
| 05 | [Diameter of Binary Tree](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/17%20-%20Binary%20Tree%20Data%20Structure%20Problems/05%20-%20Diameter%20of%20Binary%20Tree) | Find the diameter of a binary tree. | [Link](https://leetcode.com/problems/diameter-of-binary-tree/) | Non |
42+
| 06 | [Diameter of a Binary Tree](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/17%20-%20Binary%20Tree%20Data%20Structure%20Problems/06%20-%20Diameter%20of%20a%20Binary%20Tree) | Another approach to finding the diameter of a binary tree. | Non | [Link](https://www.geeksforgeeks.org/problems/diameter-of-binary-tree/1) |
43+
| 07 | [Balanced Binary Tree](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/17%20-%20Binary%20Tree%20Data%20Structure%20Problems/07%20-%20Balanced%20Binary%20Tree) | Check if a binary tree is balanced. | [Link](https://leetcode.com/problems/balanced-binary-tree/) | Non |
44+
| 08 | [Balanced Tree Check](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/17%20-%20Binary%20Tree%20Data%20Structure%20Problems/08%20-%20Balanced%20Tree%20Check) | Another method to check if a binary tree is balanced. | Non | [Link](https://www.geeksforgeeks.org/problems/check-for-balanced-tree/1) |
45+
| 09 | [Identical Trees](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/17%20-%20Binary%20Tree%20Data%20Structure%20Problems/09%20-%20Identical%20Trees) | Check if two binary trees are identical. | Non | [Link](https://www.geeksforgeeks.org/problems/determine-if-two-trees-are-identical/1) |
46+
| 10 | [Same Tree](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/17%20-%20Binary%20Tree%20Data%20Structure%20Problems/10%20-%20Same%20Tree) | Another approach to checking if two trees are identical. | [Link](https://leetcode.com/problems/same-tree/) | Non |
47+
| 11 | [Sum Tree](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/17%20-%20Binary%20Tree%20Data%20Structure%20Problems/11%20-%20Sum%20Tree) | Check if a binary tree is a sum tree. | Non | [Link](https://www.geeksforgeeks.org/problems/sum-tree/1) |
48+
| 12 | [Path Sum](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/17%20-%20Binary%20Tree%20Data%20Structure%20Problems/12%20-%20Path%20Sum) | Find if a binary tree has a root-to-leaf path with a given sum. | [Link](https://leetcode.com/problems/path-sum/) | Non |
49+
| 13 | [Binary Tree Zigzag Level Order Traversal](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/17%20-%20Binary%20Tree%20Data%20Structure%20Problems/13%20-%20Binary%20Tree%20Zigzag%20Level%20Order%20Traversal) | Perform zigzag level order traversal of a binary tree. | [Link](https://leetcode.com/problems/binary-tree-zigzag-level-order-traversal/) | Non |
50+
| 14 | [Zigzag Tree Traversal](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/17%20-%20Binary%20Tree%20Data%20Structure%20Problems/14%20-%20Zigzag%20Tree%20Traversal) | Another approach to zigzag tree traversal. | Non | [Link](https://www.geeksforgeeks.org/problems/zigzag-tree-traversal/1) |
51+
| 15 | [Tree Boundary Traversal](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/17%20-%20Binary%20Tree%20Data%20Structure%20Problems/15%20-%20Tree%20Boundary%20Traversal) | Perform boundary traversal of a binary tree. | Non | [Link](https://www.geeksforgeeks.org/problems/boundary-traversal-of-binary-tree/1) |
52+
| 16 | [Vertical Tree Traversal](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/17%20-%20Binary%20Tree%20Data%20Structure%20Problems/16%20-%20Vertical%20Tree%20Traversal) | Perform vertical traversal of a binary tree. | Non | [Link](https://www.geeksforgeeks.org/problems/print-a-binary-tree-in-vertical-order/1) |
53+
| 18 | [Top View of Binary Tree](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/17%20-%20Binary%20Tree%20Data%20Structure%20Problems/18%20-%20Top%20View%20of%20Binary%20Tree) | Find the top view of a binary tree. | Non | [Link](https://www.geeksforgeeks.org/problems/top-view-of-binary-tree/1) |
54+
| 19 | [Bottom View of Binary Tree](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/17%20-%20Binary%20Tree%20Data%20Structure%20Problems/19%20-%20Bottom%20View%20of%20Binary%20Tree) | Find the bottom view of a binary tree. | Non | [Link](https://www.geeksforgeeks.org/problems/bottom-view-of-binary-tree/1) |
55+
| 20 | [Left View of Binary Tree](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/17%20-%20Binary%20Tree%20Data%20Structure%20Problems/20%20-%20Left%20View%20of%20Binary%20Tree) | Find the left view of a binary tree. | Non | [Link](https://www.geeksforgeeks.org/problems/left-view-of-binary-tree/1) |
56+
| 21 | [Right View of Binary Tree](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/17%20-%20Binary%20Tree%20Data%20Structure%20Problems/20%20-%20Right%20View%20of%20Binary%20Tree) | Find the right view of a binary tree. | Non | [Link](https://www.geeksforgeeks.org/problems/right-view-of-binary-tree/1) |
57+
| 22 | [Binary Tree Right Side View](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/17%20-%20Binary%20Tree%20Data%20Structure%20Problems/22%20-%20Binary%20Tree%20Right%20Side%20View) | Find the right-side view of a binary tree. | [Link](https://leetcode.com/problems/binary-tree-right-side-view/description/) | Non |
58+
| 23 | [Diagonal Tree Traversal](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/17%20-%20Binary%20Tree%20Data%20Structure%20Problems/23%20-%20Diagonal%20Tree%20Traversal) | Perform diagonal traversal of a binary tree. | Non | [Link](https://www.geeksforgeeks.org/problems/diagonal-traversal-of-binary-tree/1) |
59+
| 24 | [Sum of Nodes on the Longest Path from Root to Leaf Node](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/17%20-%20Binary%20Tree%20Data%20Structure%20Problems/24%20-%20Sum%20of%20Nodes%20on%20The%20Longest%20Path%20from%20Root%20to%20Leaf%20Node) | Calculate the sum of nodes on the longest path from root to a leaf node. | Non | [Link](https://www.geeksforgeeks.org/problems/sum-of-the-longest-bloodline-of-a-tree/1) |
60+
| 25 | [LCA in Binary Tree](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/17%20-%20Binary%20Tree%20Data%20Structure%20Problems/25%20-%20LCA%20in%20Binary%20Tree) | Find the Lowest Common Ancestor (LCA) in a binary tree. | Non | [Link](https://www.geeksforgeeks.org/problems/lowest-common-ancestor-in-a-binary-tree/1?itm_source=geeksforgeeks&itm_medium=article&itm_campaign=practice_card) |
61+
| 26 | [Lowest Common Ancestor of a Binary Tree](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/17%20-%20Binary%20Tree%20Data%20Structure%20Problems/26%20-%20Lowest%20Common%20Ancestor%20of%20a%20Binary%20Tree) | Another approach to finding the LCA in a binary tree. | [Link](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree/) | Non |
62+
| 27 | [K Sum Paths](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/17%20-%20Binary%20Tree%20Data%20Structure%20Problems/27%20-%20K%20Sum%20Paths) | Find paths in a binary tree where the sum of nodes equals K. | Non | [Link](https://www.geeksforgeeks.org/problems/k-sum-paths/1) |
63+
| 28 | [Kth Ancestor in a Tree](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/17%20-%20Binary%20Tree%20Data%20Structure%20Problems/28%20-%20Kth%20Ancestor%20in%20a%20Tree) | Find the Kth ancestor of a node in a binary tree. | Non | [Link](https://www.geeksforgeeks.org/problems/kth-ancestor-in-a-tree/1) |
64+
| 29 | [Maximum Sum of Non-adjacent Nodes](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/17%20-%20Binary%20Tree%20Data%20Structure%20Problems/29%20-%20Maximum%20Sum%20of%20Non-adjacent%20Nodes) | Find the maximum sum of nodes in a binary tree such that no two adjacent nodes are selected. | Non | [Link](https://www.geeksforgeeks.org/problems/maximum-sum-of-non-adjacent-nodes/1) |
65+
| 30 | [Construct Tree From In-Order & Pre-Order](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/17%20-%20Binary%20Tree%20Data%20Structure%20Problems/30%20-%20Construct%20Tree%20From%20In-Order%20&%20Pre-Order) | Construct a binary tree from given in-order and pre-order traversals. | Non | [Link](https://www.geeksforgeeks.org/problems/construct-tree-1/1?itm_source=geeksforgeeks&itm_medium=article&itm_campaign=practice_card) |
66+
| 31 | [Binary Tree From In-Order & Post-Order](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/17%20-%20Binary%20Tree%20Data%20Structure%20Problems/31%20-%20Binary%20Tree%20From%20In-Order%20&%20Post-Order) | Construct a binary tree from given in-order and post-order traversals. | Non | [Link](https://www.geeksforgeeks.org/problems/tree-from-postorder-and-inorder/1?itm_source=geeksforgeeks&itm_medium=article&itm_campaign=practice_card) |
67+
| 32 | [Burning Tree](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/17%20-%20Binary%20Tree%20Data%20Structure%20Problems/32%20-%20Buring%20Tree) | Find the time required to burn a binary tree starting from a target node. | Non | [Link](https://www.geeksforgeeks.org/problems/burning-tree/1) |
68+
| 33 | [Amount of Time for Binary Tree to Be Infected](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/17%20-%20Binary%20Tree%20Data%20Structure%20Problems/33%20-%20Amount%20of%20Time%20for%20Binary%20Tree%20to%20Be%20Infected) | Another approach to calculating the time for a binary tree to be infected. | [Link](https://leetcode.com/problems/amount-of-time-for-binary-tree-to-be-infected/) | Non |
69+
| 34 | [Morris Traversal for Binary Trees](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/17%20-%20Binary%20Tree%20Data%20Structure%20Problems/34%20-%20Morris%20Traversal%20for%20Binary%20Trees) | Perform Morris Traversal (in-order and pre-order) for a binary tree. | Non | Non |
70+
| 35 | [Flatten Binary Tree to Linked List](https://github.com/JawadSher/DSA-LeetCode-GFG-Problems-Repository/tree/main/17%20-%20Binary%20Tree%20Data%20Structure%20Problems/35%20-%20Flatten%20Binary%20Tree%20to%20Linked%20List) | Flatten a binary tree into a linked list (in-place). | [Link](https://leetcode.com/problems/flatten-binary-tree-to-linked-list/) | Non |
71+
72+
73+
74+
75+
### Importance in Coding:
76+
Binary trees form the basis of many coding problems related to searching, pathfinding, traversal, and tree construction. They are often used to solve problems like finding the depth or height of the tree, lowest common ancestor, balanced tree checks, and more.
77+
78+
---
79+
Happy Coding 😊

0 commit comments

Comments
 (0)