forked from ajay-dhangar/algo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5ce9845
commit c71858b
Showing
2 changed files
with
91 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
--- | ||
id: tree-practice-problems | ||
title: Practice Problems on Trees | ||
sidebar_label: Practice Problems | ||
|
||
description: "In this post, we'll provide a list of curated practice problems on Trees from platforms like LeetCode and GeeksforGeeks. Trees are fundamental data structures in computer science, and practicing these problems will help strengthen your understanding of tree concepts and algorithms." | ||
|
||
tags: [dsa, algorithms, trees, practice-problems] | ||
--- | ||
|
||
## Trees Practice Problems | ||
|
||
To start solving tree problems, first ensure you understand the basic tree concepts such as traversals, node structures, and common properties. Begin by practicing easy problems to build your confidence, and gradually move to medium and hard problems as you become more comfortable. | ||
|
||
### Easy Problems | ||
|
||
- [Binary Tree Preorder Traversal](https://leetcode.com/problems/binary-tree-preorder-traversal/) | ||
- [Binary Tree Inorder Traversal](https://leetcode.com/problems/binary-tree-inorder-traversal/) | ||
- [Binary Tree Postorder Traversal](https://leetcode.com/problems/binary-tree-postorder-traversal/) | ||
- [Binary Tree Level Order Traversal](https://leetcode.com/problems/binary-tree-level-order-traversal/) | ||
- [Maximum Depth of Binary Tree](https://leetcode.com/problems/maximum-depth-of-binary-tree/) | ||
- [Same Tree](https://leetcode.com/problems/same-tree/) | ||
- [Symmetric Tree](https://leetcode.com/problems/symmetric-tree/) | ||
|
||
### Medium Problems | ||
|
||
- [Check if the Binary Tree is Height-Balanced](https://leetcode.com/problems/balanced-binary-tree/) | ||
- [Diameter of Binary Tree](https://leetcode.com/problems/diameter-of-binary-tree/) | ||
- [Height of a Binary Tree](https://leetcode.com/problems/maximum-depth-of-binary-tree/) | ||
- [Binary Tree Maximum Path Sum](https://leetcode.com/problems/binary-tree-maximum-path-sum/) | ||
- [Zigzag Level Order Traversal](https://leetcode.com/problems/binary-tree-zigzag-level-order-traversal/) | ||
- [Boundary Traversal of Binary Tree](https://leetcode.com/problems/boundary-of-binary-tree/) | ||
- [Vertical Order Traversal of Binary Tree](https://leetcode.com/problems/vertical-order-traversal-of-a-binary-tree/) | ||
- [Top View of Binary Tree](https://practice.geeksforgeeks.org/problems/top-view-of-binary-tree/1) | ||
- [Bottom View of Binary Tree](https://practice.geeksforgeeks.org/problems/bottom-view-of-binary-tree/1) | ||
|
||
### Hard Problems | ||
|
||
- [Root to Node Path in Binary Tree](https://bit.ly/3QA600D) | ||
- [Lowest Common Ancestor of a Binary Tree](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree/) | ||
- [Maximum Width of Binary Tree](https://leetcode.com/problems/maximum-width-of-binary-tree/) | ||
- [Check for Children Sum Property](https://bit.ly/3dEr73g) | ||
- [Print All Nodes at Distance K in a Binary Tree](https://leetcode.com/problems/all-nodes-distance-k-in-binary-tree/) | ||
- [Minimum Time to Burn the Binary Tree from a Node](https://bit.ly/3wcg7k1) | ||
- [Count Total Nodes in a Complete Binary Tree](https://leetcode.com/problems/count-complete-tree-nodes/) | ||
- [Requirements Needed to Construct a Unique Binary Tree | Theory](https://bit.ly/3UVCR1U) | ||
- [Construct Binary Tree from Inorder and Preorder Traversal](https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
--- | ||
id: types-of-trees | ||
title: Types of Trees | ||
sidebar_label: Types of Trees | ||
|
||
description: "This document provides an overview of various types of trees in computer science. Understanding these tree types is essential for selecting the right data structure for your specific needs." | ||
|
||
tags: [dsa, trees, data-structures] | ||
--- | ||
|
||
## Types of Trees | ||
|
||
### 1. Binary Tree | ||
A tree structure in which each node has at most two children, referred to as the left child and the right child. It is the simplest form of a tree and serves as the foundation for more complex tree structures. | ||
|
||
### 2. Binary Search Tree (BST) | ||
A binary tree in which each node follows the property that the left child contains only nodes with values less than the parent node, and the right child contains only nodes with values greater than the parent node. This property allows for efficient searching, insertion, and deletion operations. | ||
|
||
### 3. Balanced Trees | ||
Balanced trees maintain their height in a logarithmic range to ensure efficient operations. Common types include: | ||
- **AVL Tree**: A self-balancing binary search tree where the difference in heights between the left and right subtrees of any node is at most one. | ||
- **Red-Black Tree**: A binary search tree with an extra bit of storage for each node to maintain balance during insertions and deletions, ensuring that no path from the root to a leaf is more than twice as long as any other such path. | ||
|
||
### 4. Complete Binary Tree | ||
A binary tree in which all levels are fully filled except possibly for the last level, which is filled from left to right. This structure is useful for implementing heaps. | ||
|
||
### 5. Full Binary Tree | ||
A binary tree in which every node other than the leaves has two children. This property makes full binary trees a special case of complete binary trees. | ||
|
||
### 6. N-ary Tree | ||
A tree in which a node can have at most N children. N-ary trees are generalizations of binary trees and are often used to represent hierarchical data. | ||
|
||
### 7. Trie (Prefix Tree) | ||
A specialized tree structure used for storing associative data structures, particularly strings. Each node represents a single character of a key, and paths down the tree represent prefixes of keys. | ||
|
||
### 8. Segment Tree | ||
A tree data structure used for storing intervals or segments. It allows querying which segments contain a given point and is commonly used in scenarios involving range queries. | ||
|
||
### 9. B-tree | ||
A self-balancing search tree that maintains sorted data and allows searches, sequential access, insertions, and deletions in logarithmic time. B-trees are commonly used in databases and file systems. | ||
|
||
### 10. B+ Tree | ||
An extension of the B-tree that maintains sorted data and allows for efficient range queries. In a B+ tree, all values are stored at the leaf level, making it particularly suitable for database systems. |