Skip to content

Commit 1314fae

Browse files
committed
update chapters with external resrouces
1 parent 1f26c09 commit 1314fae

File tree

6 files changed

+78
-14
lines changed

6 files changed

+78
-14
lines changed

markdowns/Ch23-Trees.md

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
# Trees
22
<a href="https://colab.research.google.com/github/rambasnet/Python-Fundamentals/blob/master/notebooks/Ch23-Trees.ipynb" target="_parent"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/></a>
33

4-
http://openbookproject.net/thinkcs/python/english3e/trees.html
5-
- like linked lists, trees are made up of nodes
4+
## External Resources
5+
- Think Python - [http://openbookproject.net/thinkcs/python/english3e/trees.html](http://openbookproject.net/thinkcs/python/english3e/trees.html)
6+
7+
8+
## Overview
9+
10+
- like linked lists, trees are made up of nodes or objects that contain data and references to other nodes
11+
- unlike linked lists, trees can have multiple references to other nodes
12+
- trees are hierarchical data structures that are used to represent relationships between data items
13+
- trees are widely used in computer science for various applications such as searching, sorting, and organizing data
14+
- common types of trees include binary trees, binary search trees, AVL trees, and B-trees, etc.
615

716
## Binary Tree
817
- is a commonly used tree in which each node contains a reference to atmost two other nodes (possibly None)
@@ -11,6 +20,11 @@ http://openbookproject.net/thinkcs/python/english3e/trees.html
1120
- like linked lists, trees are recursive data structures that are defined recursively:
1221
1. the empty tree, represented by None, or
1322
2. a node that contains a data and two tree references (left and right subtree)
23+
- the topmost node in the tree is called the root node
24+
- nodes with no children are called leaf nodes
25+
- nodes that are not leaf nodes are called internal nodes
26+
- the height of a tree is the length of the longest path from the root to a leaf
27+
- trees can be traversed in different ways such as inorder, preorder, and postorder traversal
1428

1529
## Building trees
1630
- similar to building linked-list
@@ -60,7 +74,15 @@ print(tree1)
6074

6175

6276
## traversing tree
77+
6378
- natural way to traverse a tree is recursively!
79+
- for each node, visit the node and then recursively visit its left and right subtrees
80+
- three common ways to traverse a binary tree:
81+
- inorder traversal
82+
- preorder traversal
83+
- postorder traversal
84+
- each traversal visits the nodes in a different order and is useful for different applications
85+
6486

6587

6688
```python
@@ -116,13 +138,15 @@ expression = Tree('+', Tree(1), Tree('*', Tree(2), Tree(3)))
116138
```
117139

118140
### pre-order tree traversal
141+
119142
- contents of the root appear before the contents of the children
120143
- recursive algorithm:
121144
- visit the node
122-
- visit left subtree
145+
- visit left subtree
123146
- visit right subtree
124147

125148

149+
126150
```python
127151
def preorder(tree):
128152
if not tree:

notebooks/Ch04-Conditionals.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"## External Resources\n",
1919
"\n",
2020
"- YouTube Video - [https://youtu.be/59dZxyidO0k](https://youtu.be/59dZxyidO0k)\n",
21-
"- YouTube Podcast - [https://youtu.be/cSypvtZ3wCQ](https://youtu.be/cSypvtZ3wCQ)\n",
21+
"- YouTube Podcast - [https://youtu.be/uAEaTBj8amY](https://youtu.be/uAEaTBj8amY)\n",
2222
"- NotebookLM learning resources - [https://notebooklm.google.com/notebook/63f84517-0108-46f3-95ae-5b88a91dc288](https://notebooklm.google.com/notebook/63f84517-0108-46f3-95ae-5b88a91dc288)\n",
2323
"\n",
2424
"## Conditional/Logical Structures\n",

notebooks/Ch09-2-Built-in-DataStructures.ipynb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,12 @@
1212
"cell_type": "markdown",
1313
"metadata": {},
1414
"source": [
15-
"- all builtin functions are listed here with examples: https://docs.python.org/3/library/functions.html\n",
1615
"\n",
16+
"## External Resources\n",
17+
"- all builtin functions are listed here with examples: https://docs.python.org/3/library/functions.html\n",
18+
"- YouTube Video - [https://youtu.be/gINs_P8iyI8](https://youtu.be/gINs_P8iyI8)\n",
19+
"- YouTube Podcast - [https://youtu.be/4uth7ylvu9k](https://youtu.be/4uth7ylvu9k)\n",
20+
"- NotebookLM learning resources - [https://notebooklm.google.com/notebook/444b976d-bdd4-4668-8f90-66c0b9866f9e](https://notebooklm.google.com/notebook/444b976d-bdd4-4668-8f90-66c0b9866f9e)\n",
1721
"\n",
1822
"## zip( )\n",
1923
"- built-in zip class can help us quickly create list of tuples and then a dictionary"

notebooks/Ch21-Stacks.ipynb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@
77
"# Stacks\n",
88
"<a href=\"https://colab.research.google.com/github/rambasnet/Python-Fundamentals/blob/master/notebooks/Ch21-Stacks.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>\n",
99
"\n",
10-
"http://openbookproject.net/thinkcs/python/english3e/stacks.html\n",
10+
"## External Resources\n",
11+
"\n",
12+
"- Think Python - [http://openbookproject.net/thinkcs/python/english3e/stacks.html](http://openbookproject.net/thinkcs/python/english3e/stacks.html)\n",
13+
"- YouTube Video - [https://youtu.be/UXjpI8zFBjo](https://youtu.be/UXjpI8zFBjo)\n",
14+
"- YouTube Podcast - [https://youtu.be/nuro24feUMc](https://youtu.be/nuro24feUMc)\n",
15+
"- NotebookLM learning resources - [https://notebooklm.google.com/notebook/1c\n",
1116
"\n",
1217
"- container adapters or abstract data type (ADT) that may use list or linked-list as containers to hold data\n",
1318
"- specifically designed to operate as a LIFO (last-in-first-out) or FILO (first-in-last-out) data structure \n",

notebooks/Ch22-Queues.ipynb

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,19 @@
77
"# Queues\n",
88
"<a href=\"https://colab.research.google.com/github/rambasnet/Python-Fundamentals/blob/master/notebooks/Ch22-Queues.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>\n",
99
"\n",
10-
"http://openbookproject.net/thinkcs/python/english3e/queues.html\n",
10+
"## External Resources\n",
11+
"- Think Python - [http://openbookproject.net/thinkcs/python/english3e/queues.html](http://openbookproject.net/thinkcs/python/english3e/queues.html)\n",
12+
"- YouTube Video - [https://youtu.be/V1aQfaHWGNQ](https://youtu.be/V1aQfaHWGNQ)\n",
13+
"- YouTube Podcast - [https://youtu.be/RVmdAAHpqwA](https://youtu.be/RVmdAAHpqwA)\n",
14+
"- NotebookLM learning resources - [https://notebooklm.google.com/notebook/3fa6e2\n",
15+
"\n",
16+
"\n",
17+
"## Overview\n",
1118
"- another container adapter or ADT, which is typically a first-in-first-out (FIFO) data structure\n",
1219
"- mimics real-world queue/line of people waiting for something\n",
1320
"- rule that determines who goes next is called the queuing policy\n",
1421
"- the most general queuing policy is priority queuing, in which each item/person is assigned a priority and the element with highest priority goes first, regardless of the order of the arrival\n",
15-
"- built-in alternative - deque: https://docs.python.org/3/library/collections.html#collections.deque"
22+
"- built-in alternative - deque: https://docs.python.org/3/library/collections.html#collections.deque\n"
1623
]
1724
},
1825
{

notebooks/Ch23-Trees.ipynb

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,32 @@
77
"# Trees\n",
88
"<a href=\"https://colab.research.google.com/github/rambasnet/Python-Fundamentals/blob/master/notebooks/Ch23-Trees.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>\n",
99
"\n",
10-
"http://openbookproject.net/thinkcs/python/english3e/trees.html\n",
11-
"- like linked lists, trees are made up of nodes\n",
10+
"## External Resources\n",
11+
"- Think Python - [http://openbookproject.net/thinkcs/python/english3e/trees.html](http://openbookproject.net/thinkcs/python/english3e/trees.html)\n",
12+
"- YouTube Video - [https://youtu.be/8ZUsDn98hNY](https://youtu.be/8ZUsDn98hNY)\n",
13+
"- YouTube Podcast - [https://youtu.be/wj0s8OIzcX4](https://youtu.be/wj0s8OIzcX4)\n",
14+
"- NotebookLM learning resources - [https://notebooklm.google.com/notebook/eb7913fe-030f-43aa-a2f3-1c15cabac10c](https://notebooklm.google.com/notebook/eb7913fe-030f-43aa-a2f3-1c15cabac10c)\n",
15+
"\n",
16+
"## Overview\n",
17+
"\n",
18+
"- like linked lists, trees are made up of nodes or objects that contain data and references to other nodes\n",
19+
"- unlike linked lists, trees can have multiple references to other nodes\n",
20+
"- trees are hierarchical data structures that are used to represent relationships between data items\n",
21+
"- trees are widely used in computer science for various applications such as searching, sorting, and organizing data\n",
22+
"- common types of trees include binary trees, binary search trees, AVL trees, and B-trees, etc.\n",
1223
"\n",
1324
"## Binary Tree\n",
1425
" - is a commonly used tree in which each node contains a reference to atmost two other nodes (possibly None)\n",
1526
"- these references are referred to as the left and right subtrees\n",
1627
"- like the node of linked list, each node also contains data/cargo\n",
1728
"- like linked lists, trees are recursive data structures that are defined recursively:\n",
1829
" 1. the empty tree, represented by None, or\n",
19-
" 2. a node that contains a data and two tree references (left and right subtree)"
30+
" 2. a node that contains a data and two tree references (left and right subtree)\n",
31+
"- the topmost node in the tree is called the root node\n",
32+
"- nodes with no children are called leaf nodes\n",
33+
"- nodes that are not leaf nodes are called internal nodes\n",
34+
"- the height of a tree is the length of the longest path from the root to a leaf\n",
35+
"- trees can be traversed in different ways such as inorder, preorder, and postorder traversal"
2036
]
2137
},
2238
{
@@ -111,7 +127,14 @@
111127
"metadata": {},
112128
"source": [
113129
"## traversing tree\n",
114-
"- natural way to traverse a tree is recursively!"
130+
"\n",
131+
"- natural way to traverse a tree is recursively!\n",
132+
"- for each node, visit the node and then recursively visit its left and right subtrees\n",
133+
"- three common ways to traverse a binary tree:\n",
134+
" - inorder traversal\n",
135+
" - preorder traversal\n",
136+
" - postorder traversal\n",
137+
"- each traversal visits the nodes in a different order and is useful for different applications\n"
115138
]
116139
},
117140
{
@@ -201,11 +224,12 @@
201224
"metadata": {},
202225
"source": [
203226
"### pre-order tree traversal\n",
227+
"\n",
204228
"- contents of the root appear before the contents of the children\n",
205229
"- recursive algorithm:\n",
206230
" - visit the node\n",
207-
" - visit left subtree\n",
208-
" - visit right subtree"
231+
" - visit left subtree \n",
232+
" - visit right subtree\n"
209233
]
210234
},
211235
{

0 commit comments

Comments
 (0)