Skip to content

Commit 79724de

Browse files
authored
GH-239: Tree in General (#240)
1 parent 59eb343 commit 79724de

File tree

6 files changed

+43
-5
lines changed

6 files changed

+43
-5
lines changed

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,8 @@ A data structure is a data organization, management, and storage format that is
105105
<a href="/concepts/cpp/priority_queue.md"><code>cpp🐀</code></a>
106106
</li>
107107
<li>
108-
<code>A</code> Tree
109-
<a href="/concepts/cpp/tree.md"><code>cpp🐀</code></a>
110-
<a href="/concepts/python/tree.md"><code>py🐍</code></a>
108+
<code>A</code>
109+
<a href="/concepts/general/tree/README.md">Tree</a>
111110
<ul>
112111
<li><code>A</code> Binary Search Tree</li>
113112
<li><code>A</code> AVL Tree</li>
File renamed without changes.

concepts/general/tree/README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Tree
2+
3+
*See implementation in*
4+
[C++](/concepts/cpp/tree/README.md),
5+
Java,
6+
[Python](/concepts/python/tree/README.md),
7+
Typescript,
8+
9+
10+
Tree is a data structure that consists of nodes in a parent / child relationship. A tree can be empty with no nodes or a tree is a structure consisting of one node called the root and zero or one or more subtrees.
11+
12+
Tree are prefered over arrays when we need to search for a specific value or when we need to insert/delete a value.
13+
14+
## Type of Trees
15+
16+
* Binary Tree: A tree whose elements have at most 2 children is called a binary tree. Since each element in a binary tree can have only 2 children, we typically name them the left and right child.
17+
* Binary Search Tree: A binary search tree (BST) is a node-based binary tree data structure which has the following properties:
18+
* The left subtree of a node contains only nodes with keys less than the node's key.
19+
* The right subtree of a node contains only nodes with keys greater than the node's key.
20+
* The left and right subtree each must also be a binary search tree.
21+
* AVL Tree: An AVL tree is a self-balancing binary search tree. It was the first such data structure to be invented. In an AVL tree, the heights of the two child subtrees of any node differ by at most one; if at any time they differ by more than one, rebalancing is done to restore this property.
22+
* Red-Black Tree: A red–black tree is a kind of self-balancing binary search tree in computer science. Each node of the binary tree has an extra bit, and that bit is often interpreted as the color (red or black) of the node. These color bits are used to ensure the tree remains approximately balanced during insertions and deletions.
23+
* Segment Tree: A segment tree is a tree data structure for storing intervals, or segments. It allows querying which of the stored segments contain a given point.
24+
* Fenwick Tree: A Fenwick tree or binary indexed tree is a data structure that can efficiently update elements and calculate prefix sums in a table of numbers.
25+
26+
## Tree Operations
27+
28+
Here are some basic operations that you can perform on trees:
29+
30+
* Initialization: Create a tree with given value
31+
* Traversal: Visit all nodes of the tree
32+
* Insertion: Insert a node in the tree
33+
* Deletion: Delete a node from the tree
34+
35+
## 🔗 Further Reading
36+
37+
* [Tree (data structure)](https://en.wikipedia.org/wiki/Tree_(data_structure)), wikipedia
38+
* ▶️ [Introduction to tree algorithms](https://www.youtube.com/watch?v=1XC3p2zBK34&list=PLDV1Zeh2NRsDfGc8rbQ0_58oEZQVtvoIc&ab_channel=WilliamFiset), WilliamFiset
39+
* ▶️ [Beginner tree algorithms](https://www.youtube.com/watch?v=0qgaIMqOEVs&list=PLDV1Zeh2NRsDfGc8rbQ0_58oEZQVtvoIc&index=2&ab_channel=WilliamFiset), WilliamFiset
File renamed without changes.

readme/cpp/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ A data structure is a data organization, management, and storage format that is
5353
</li>
5454
<li>
5555
<code>A</code>
56-
<a href="/concepts/cpp/tree.md">Tree</a>
56+
<a href="/concepts/cpp/tree/README.md">Tree</a>
5757
<ul>
5858
<li><code>A</code> Binary Search Tree</li>
5959
<li><code>A</code> AVL Tree</li>

readme/python/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ Priority Queue
5656
</li>
5757
<li>
5858
<code>A</code>
59-
<a href="/concepts/python/tree.md">Tree</a>
59+
<a href="/concepts/python/tree/README.md">Tree</a>
6060
<ul>
6161
<li><code>A</code> Binary Search Tree</li>
6262
<li><code>A</code> AVL Tree</li>

0 commit comments

Comments
 (0)