Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 390610c

Browse files
update the tree readme file
1 parent 338afc1 commit 390610c

File tree

1 file changed

+20
-6
lines changed
  • src/main/java/ir/sk/adt/datastructure/tree

1 file changed

+20
-6
lines changed

‎src/main/java/ir/sk/adt/datastructure/tree/tree.md‎

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,29 @@
44
Trees are hierarchical data structures that consist of nodes connected by edges. Each tree has a root node, and every node can have zero or more child nodes. Trees are widely used in computer science for various applications, including representing hierarchical data, parsing expressions, and implementing search algorithms.
55

66
## Types of Binary Trees:
7-
Full Binary Tree: A full binary tree is a binary tree where every node has exactly 0 or 2 children.
7+
Full Binary Tree: A full binary tree is a binary tree where every node has exactly 0 or 2 children.\
8+
* Internal nodes always have exactly two children.
9+
* Leaf nodes may be at different depths.
10+
* Not necessarily balanced.
11+
Real-world Use Cases:
12+
* Represent arithmetic expressions like (a + b) * (c - d).
13+
Internal nodes = operators (+, -, *, /), leaf nodes = operands (a, b, c, d).
14+
Always full, since every operator needs exactly two operands.
15+
* Parsing Trees: Used in compilers to represent syntax structures where binary grammar rules apply.
16+
817
```
9-
A
10-
/ \
11-
B C
12-
/ \
13-
D E
18+
A A
19+
/ \ / \
20+
B C B C
21+
/ \ / \
22+
D E F G
1423
```
1524
Complete Binary Tree: A complete binary tree is a binary tree in which every level, except possibly the last, is completely filled, and all nodes are as far left as possible.
25+
* All leaf nodes are as far left as possible.
26+
* Very efficient memory representation using arrays (no gaps).
27+
* Not necessarily full or perfect.
28+
Real-world Use Cases:
29+
1630
```
1731
A
1832
/ \

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /