From 9934bbf6956d727d2979c7fbfb3b2f651d5bb98c Mon Sep 17 00:00:00 2001
From: Ahmed Abou Gabal <78806824+ahmedabougabal@users.noreply.github.com>
Date: Fri, 24 Jan 2025 23:53:42 +0200
Subject: [PATCH] doc: adds my taken notes of binary tree traversal and adds
docs for a nice way to print them visually without coding on a paper
---
README.md | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 70 insertions(+)
diff --git a/README.md b/README.md
index 3db035b..989f60d 100644
--- a/README.md
+++ b/README.md
@@ -65,6 +65,72 @@
-- A linked List is a special case of a binary tree.
+---
+# binary tree traversal 1
+
+traversal is a way of walking through an elements of a data structure.
+
+we need to create an expression tree (leaves are operands and others are operators)
+
+can draw this tree : (2+3)\*4
+
+# types of traversal
+
+- LVR (left, visit, right) --> in order traversal
+
+how to know the printed nodes visually ?
+
+
+project down each node and read from left to right, this is how the binary tree is represented visually as shown.
+
+
+
+
+---
+
+- LRV (left, right, visit) --> post order traversal
+
+ --> left first, then right first , then printing the nodes
+
+ how to deduce the printed nodes visually ?
+
+just in 2 steps :
+
+**step 1**
+for every node , if it doesnot have a right , then project it down, what if it does have a right node? --> wait for it
+
+**step 2**
+
+for the nodes that have a right node , project it down after its right node.
+
+note that, when projecting the nodes in step 2 , we go from bottom to up level by level.
+
+
+
+---
+
+- VLR (visit, left, right) --> preorder traversal
+
+ how to deduce the printed nodes visually ?
+
+will be the opposite of the post order traversal (2 steps)
+
+**step 1**
+for every node , if it doesnot have a left, then project it down, what if it does have a left node? --> wait for it
+
+**step 2**
+then we project the nodes that have a left node before its left subtrees
+
+
+- note that, when projecting the nodes in step 2 , we go from bottom to up level by level.
+
+
+
+
+
+
+
+---
# BFS Tree Structure explanation for the 'whatTasteIsItLike.py' question :
**initial state**
@@ -199,6 +265,10 @@ So when we say "red found!", we mean:
+
+
+
+
---