first commit, add all prev working files
@ -0,0 +1,12 @@
|
|||||||
|
# ABOUT
|
||||||
|
A series of programs that builds on the tree structure, an abstract data
|
||||||
|
type used for presenting, storing and searching information
|
||||||
|
|
||||||
|
# VALUE IN MEDIA ARCHAEOLOGY
|
||||||
|
# VALUE IN CRITICAL STUDIES
|
||||||
|
# FORMAT
|
||||||
|
Textual outputs are stored as txt files, and image outputs are stored as image files. The program process is stored in Jupyter Notebooks.
|
||||||
|
# WHERE IS THIS FORKED FROM
|
||||||
|
# FORK YOUR OWN
|
||||||
|
|
||||||
|
|
@ -0,0 +1,79 @@
|
|||||||
|
{
|
||||||
|
"cells": [
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "666a35e1-435d-4555-8193-9258ff568e21",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"class letterLeaf:\n",
|
||||||
|
" def __init__(self,question):\n",
|
||||||
|
" self.yes = None\n",
|
||||||
|
" self.no = None\n",
|
||||||
|
" self.question = question\n"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "254b714a-2504-4cc0-9a78-21d406ddbb2f",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"# tree traversals, here to print stuff \n",
|
||||||
|
"def inorder(treeName):\n",
|
||||||
|
" if treeName:\n",
|
||||||
|
" inorder(treeName.yes)\n",
|
||||||
|
" print(treeName.question)\n",
|
||||||
|
" inorder(treeName.no)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "e8512457-7944-4604-92c7-29f90ab6c3db",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"# interactive user input utility \n",
|
||||||
|
"def saysYes(ques):\n",
|
||||||
|
" while True:\n",
|
||||||
|
" ans = input(ques)\n",
|
||||||
|
" ans = ans[0:1].lower()\n",
|
||||||
|
" if ans == 'y': return True\n",
|
||||||
|
" else : return False"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "8415d1d2-211a-4e82-b331-85527e8c1510",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"reference\n",
|
||||||
|
"https://web.stonehill.edu/compsci/CS211/Assignmenta%202015/TreeAssignment.pdf"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"kernelspec": {
|
||||||
|
"display_name": "Python 3 (ipykernel)",
|
||||||
|
"language": "python",
|
||||||
|
"name": "python3"
|
||||||
|
},
|
||||||
|
"language_info": {
|
||||||
|
"codemirror_mode": {
|
||||||
|
"name": "ipython",
|
||||||
|
"version": 3
|
||||||
|
},
|
||||||
|
"file_extension": ".py",
|
||||||
|
"mimetype": "text/x-python",
|
||||||
|
"name": "python",
|
||||||
|
"nbconvert_exporter": "python",
|
||||||
|
"pygments_lexer": "ipython3",
|
||||||
|
"version": "3.9.7"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 5
|
||||||
|
}
|
@ -0,0 +1,46 @@
|
|||||||
|
{
|
||||||
|
"cells": [
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "baf7d8e8-1cc2-4f18-b5a7-ce5bb7c45bef",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"# a cutting tree"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "b6057018-bdeb-429a-8e66-130419251ef9",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"# during an evening walk after the marshall fire, i saw a local\n",
|
||||||
|
"# tree trimming company handling trees that were either entirely \n",
|
||||||
|
"# fallen off or were dangling. the trees needed to be removed as\n",
|
||||||
|
"# they may be of hazard for the pedestrians and the road. "
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"kernelspec": {
|
||||||
|
"display_name": "Python 3 (ipykernel)",
|
||||||
|
"language": "python",
|
||||||
|
"name": "python3"
|
||||||
|
},
|
||||||
|
"language_info": {
|
||||||
|
"codemirror_mode": {
|
||||||
|
"name": "ipython",
|
||||||
|
"version": 3
|
||||||
|
},
|
||||||
|
"file_extension": ".py",
|
||||||
|
"mimetype": "text/x-python",
|
||||||
|
"name": "python",
|
||||||
|
"nbconvert_exporter": "python",
|
||||||
|
"pygments_lexer": "ipython3",
|
||||||
|
"version": "3.9.7"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 5
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
{
|
||||||
|
"cells": [
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "b8bb6f10-0461-4fb9-9f36-9b64ae33405c",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"# a genetic tree"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"kernelspec": {
|
||||||
|
"display_name": "Python 3 (ipykernel)",
|
||||||
|
"language": "python",
|
||||||
|
"name": "python3"
|
||||||
|
},
|
||||||
|
"language_info": {
|
||||||
|
"codemirror_mode": {
|
||||||
|
"name": "ipython",
|
||||||
|
"version": 3
|
||||||
|
},
|
||||||
|
"file_extension": ".py",
|
||||||
|
"mimetype": "text/x-python",
|
||||||
|
"name": "python",
|
||||||
|
"nbconvert_exporter": "python",
|
||||||
|
"pygments_lexer": "ipython3",
|
||||||
|
"version": "3.9.7"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 5
|
||||||
|
}
|
@ -0,0 +1,383 @@
|
|||||||
|
{
|
||||||
|
"cells": [
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "59b5e56e-137c-4c72-8832-3fb7e625fddc",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"# a longan tree\n",
|
||||||
|
"# 龙眼树"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "1d3d5765-21b5-4022-8fb6-995feadbd000",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"## what is longan?\n",
|
||||||
|
"Dimocarpus longan, commonly known as the longan, is a tropical tree species that produces edible fruit. It is one of the better-known tropical members of the soapberry family Sapindaceae,to which the lychee and rambutan also belong. The fruit of the longan is similar to that of the lychee, but less aromatic in taste."
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "8bd7458b-bbb1-4977-9f78-a4f8f2e93985",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"### a photo of a longan tree with fruits\n",
|
||||||
|
"from reddit post https://www.reddit.com/r/gardening/comments/8cfh6n/our_glorious_longan_tree/"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 12,
|
||||||
|
"id": "39a00b5f-45ca-4356-ad0e-b2cef2593ef1",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"data": {
|
||||||
|
"text/html": [
|
||||||
|
"<img src=\"img/longan_tree.jpg\" width=\"400\" height=\"400\"/>"
|
||||||
|
],
|
||||||
|
"text/plain": [
|
||||||
|
"<IPython.core.display.Image object>"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"execution_count": 12,
|
||||||
|
"metadata": {},
|
||||||
|
"output_type": "execute_result"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"from IPython.display import Image\n",
|
||||||
|
"url_tree = \"images/longan_tree.jpg\"\n",
|
||||||
|
"Image(url= url_tree, width=400, height=400)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "547e4b39-856f-4374-a23a-b95917817749",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"## what is the soapberry family Sapindaceae?\n",
|
||||||
|
"The Sapindaceae are a family of flowering plants in the order Sapindales known as the soapberry family. \n"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "9a0050aa-eabb-4407-971e-abd89f9ddb17",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"### why is knowing the soapberry family important for the longan tree"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "68ba1fba-d0f0-4e6f-952b-07ae19262df8",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"As we know the longan tree is one tree species under the soapberry family, we can track the other tree species relevant to the longan tree. The lychee tree, the rambutan tree, and the longan tree are closely related to each other. "
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "0af3e49f-f417-4779-afc8-9932be9539f5",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"This is written in early spring, and longan fruits are harvested during the summer. In villages in Southern China, harvesting longan fruits \"摘龙眼\"is a fun summer activity. "
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "7ba8cd22-532f-424c-8c57-96990a8903fd",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"Longan also means \"dragon eye\". The fruit is round, resembling an eyeball of a dragon. There is also the \"phoenix eye\"(凤眼),referring to eyes that has a long-ish shape and tilts upwards. "
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "3f133efd-1adf-40f0-acb6-24fbff03bebb",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"In a gender binary context, suppose there is a pair of twins that's a boy and a girl. In Chinese such pair of twins is refered to as \"dragon and phoenix twin\"(龙凤胎)。Suppose the girl has the \"phonenix eyes\"(凤眼), then would the boy eat loads of \"dragon eyes\"(龙眼)?!\n",
|
||||||
|
"在性别二元对立的语境下,有一对龙凤胎,女孩有一双凤眼,那男孩岂不是有一双龙眼?!"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 23,
|
||||||
|
"id": "23f11815-0327-4027-8e4a-6004595e9525",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"eyes_l = [\"⊙\",\"ಠ\",\"ಡ\",\"⚆\",\n",
|
||||||
|
" \"✪\",\"◙\",\"*\",\"°\",\n",
|
||||||
|
" \"☉\",\"⚈\",\"๏\",\"◔\",\n",
|
||||||
|
" \"◉\",\"ʘ\",\"Θ\",\"❍\",\n",
|
||||||
|
" \"●\",\"ᓂ\",\"ᓀ\",\"•͈\",\n",
|
||||||
|
" ]"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "e9181f99-311b-4788-bba1-3781b62dc7f8",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"## dragon eyes of various affects\n",
|
||||||
|
"呆萌的龙眼,迟疑的龙眼,左顾右盼的龙眼,闪烁其辞的龙眼。\n",
|
||||||
|
"被踩扁的龙眼,爆了浆的龙眼,剥开皮的龙眼,被掏空的龙眼。"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 24,
|
||||||
|
"id": "f74f4027-9305-4862-adb9-3bd46bae37ad",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"# build a tree from eyes_l\n",
|
||||||
|
"# can try a binary tree structure\n",
|
||||||
|
"# however, a longan tree cannot be arbitrarily defined as using\n",
|
||||||
|
"# the bst structure\n",
|
||||||
|
"# are there other tree branching structures to try? "
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 25,
|
||||||
|
"id": "35a275f8-71d4-4354-b019-befc9650c042",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"# starting from a yard of trees: longan, lychee and rombutan "
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 26,
|
||||||
|
"id": "fe8cc549-0ffe-4d55-afb3-a49605fca2c1",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"soapberry forest\n",
|
||||||
|
"├── longan\n",
|
||||||
|
"├── lychee\n",
|
||||||
|
"└── rombutan\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"from anytree import Node, RenderTree\n",
|
||||||
|
"# build tree\n",
|
||||||
|
"soapberryForest = Node(\"soapberry forest\")\n",
|
||||||
|
"longan = Node(\"longan\", parent=soapberryForest)\n",
|
||||||
|
"lychee = Node(\"lychee\", parent=soapberryForest)\n",
|
||||||
|
"rombutan = Node(\"rombutan\", parent=soapberryForest)\n",
|
||||||
|
"\n",
|
||||||
|
"# print tree\n",
|
||||||
|
"for pre, fill, node in RenderTree(soapberryForest):\n",
|
||||||
|
"\tprint(\"%s%s\" %(pre,node.name))"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 27,
|
||||||
|
"id": "a651378f-02e3-4da4-8510-3754af471cc2",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"# bst tree template \n",
|
||||||
|
"\"\"\"Python3 program to demonstrate insert\n",
|
||||||
|
"operation in binary search tree \"\"\"\n",
|
||||||
|
"\n",
|
||||||
|
"# A Binary Tree Node\n",
|
||||||
|
"# Utility function to create a\n",
|
||||||
|
"# new tree node\n",
|
||||||
|
"class newNode:\n",
|
||||||
|
"\n",
|
||||||
|
" # Constructor to create a newNode\n",
|
||||||
|
" def __init__(self, data):\n",
|
||||||
|
" self.key= data\n",
|
||||||
|
" self.left = None\n",
|
||||||
|
" self.right = self.parent = None\n",
|
||||||
|
"\n",
|
||||||
|
"# A utility function to insert a new\n",
|
||||||
|
"# Node with given key in BST\n",
|
||||||
|
"def insert(root, key):\n",
|
||||||
|
"\n",
|
||||||
|
" # Create a new Node containing\n",
|
||||||
|
" # the new element\n",
|
||||||
|
" newnode = newNode(key)\n",
|
||||||
|
"\n",
|
||||||
|
" # Pointer to start traversing from root\n",
|
||||||
|
" # and traverses downward path to search\n",
|
||||||
|
" # where the new node to be inserted\n",
|
||||||
|
" x = root\n",
|
||||||
|
"\n",
|
||||||
|
" # Pointer y maintains the trailing\n",
|
||||||
|
" # pointer of x\n",
|
||||||
|
" y = None\n",
|
||||||
|
"\n",
|
||||||
|
" while (x != None):\n",
|
||||||
|
" y = x\n",
|
||||||
|
" if (key < x.key):\n",
|
||||||
|
" x = x.left\n",
|
||||||
|
" else:\n",
|
||||||
|
" x = x.right\n",
|
||||||
|
" \n",
|
||||||
|
" # If the root is None i.e the tree is\n",
|
||||||
|
" # empty. The new node is the root node\n",
|
||||||
|
" if (y == None):\n",
|
||||||
|
" y = newnode\n",
|
||||||
|
"\n",
|
||||||
|
" # If the new key is less then the leaf node key\n",
|
||||||
|
" # Assign the new node to be its left child\n",
|
||||||
|
" elif (key < y.key):\n",
|
||||||
|
" y.left = newnode\n",
|
||||||
|
"\n",
|
||||||
|
" # else assign the new node its\n",
|
||||||
|
" # right child\n",
|
||||||
|
" else:\n",
|
||||||
|
" y.right = newnode\n",
|
||||||
|
"\n",
|
||||||
|
" # Returns the pointer where the\n",
|
||||||
|
" # new node is inserted\n",
|
||||||
|
" return y\n",
|
||||||
|
"\n",
|
||||||
|
"#Driver Code\n",
|
||||||
|
"if __name__ == '__main__':\n",
|
||||||
|
"\n",
|
||||||
|
" root = None\n",
|
||||||
|
" root = insert(root, \"longan tree\")\n",
|
||||||
|
" for eye in eyes_l:\n",
|
||||||
|
" insert(root,eye)\n",
|
||||||
|
"\n"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 28,
|
||||||
|
"id": "ef3979c3-7da9-4bb3-a691-4a210da308cb",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"\n",
|
||||||
|
" ❍\n",
|
||||||
|
"\n",
|
||||||
|
" ✪\n",
|
||||||
|
"\n",
|
||||||
|
" ⚈\n",
|
||||||
|
"\n",
|
||||||
|
" ⚆\n",
|
||||||
|
"\n",
|
||||||
|
" ☉\n",
|
||||||
|
"\n",
|
||||||
|
" ◙\n",
|
||||||
|
"\n",
|
||||||
|
" ◔\n",
|
||||||
|
"\n",
|
||||||
|
" ●\n",
|
||||||
|
"\n",
|
||||||
|
" ◉\n",
|
||||||
|
"\n",
|
||||||
|
" ⊙\n",
|
||||||
|
"\n",
|
||||||
|
" •͈\n",
|
||||||
|
"\n",
|
||||||
|
" ᓂ\n",
|
||||||
|
"\n",
|
||||||
|
" ᓀ\n",
|
||||||
|
"\n",
|
||||||
|
" ๏\n",
|
||||||
|
"\n",
|
||||||
|
" ಡ\n",
|
||||||
|
"\n",
|
||||||
|
" ಠ\n",
|
||||||
|
"\n",
|
||||||
|
" Θ\n",
|
||||||
|
"\n",
|
||||||
|
" ʘ\n",
|
||||||
|
"\n",
|
||||||
|
" °\n",
|
||||||
|
"\n",
|
||||||
|
"longan tree\n",
|
||||||
|
"\n",
|
||||||
|
" *\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"COUNT = [10]\n",
|
||||||
|
"def print2DUtil(root, space) :\n",
|
||||||
|
"\n",
|
||||||
|
" # Base case\n",
|
||||||
|
" if (root == None) :\n",
|
||||||
|
" return\n",
|
||||||
|
"\n",
|
||||||
|
" # Increase distance between levels\n",
|
||||||
|
" space += COUNT[0]\n",
|
||||||
|
"\n",
|
||||||
|
" # Process right child first\n",
|
||||||
|
" print2DUtil(root.right, space)\n",
|
||||||
|
"\n",
|
||||||
|
" # Print current node after space\n",
|
||||||
|
" # count\n",
|
||||||
|
" print()\n",
|
||||||
|
" for i in range(COUNT[0], space):\n",
|
||||||
|
" print(end = \" \")\n",
|
||||||
|
" print(root.key)\n",
|
||||||
|
"\n",
|
||||||
|
" # Process left child\n",
|
||||||
|
" print2DUtil(root.left, space)\n",
|
||||||
|
"\n",
|
||||||
|
"# Wrapper over print2DUtil()\n",
|
||||||
|
"def print2D(root) :\n",
|
||||||
|
" \n",
|
||||||
|
" # space=[0]\n",
|
||||||
|
" # Pass initial space count as 0\n",
|
||||||
|
" print2DUtil(root, 0)\n",
|
||||||
|
"\n",
|
||||||
|
"# Driver Code\n",
|
||||||
|
"if __name__ == '__main__':\n",
|
||||||
|
"\n",
|
||||||
|
" \n",
|
||||||
|
" print2D(root)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "d8d8b5fa-49cf-47e5-8c69-a0285b286030",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"a pun, a poem, a puoem. "
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"kernelspec": {
|
||||||
|
"display_name": "Python 3 (ipykernel)",
|
||||||
|
"language": "python",
|
||||||
|
"name": "python3"
|
||||||
|
},
|
||||||
|
"language_info": {
|
||||||
|
"codemirror_mode": {
|
||||||
|
"name": "ipython",
|
||||||
|
"version": 3
|
||||||
|
},
|
||||||
|
"file_extension": ".py",
|
||||||
|
"mimetype": "text/x-python",
|
||||||
|
"name": "python",
|
||||||
|
"nbconvert_exporter": "python",
|
||||||
|
"pygments_lexer": "ipython3",
|
||||||
|
"version": "3.9.7"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 5
|
||||||
|
}
|
@ -0,0 +1,49 @@
|
|||||||
|
{
|
||||||
|
"cells": [
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "23070ca4-55cc-4a58-97d5-cb2fcb9c30a2",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"# todo \n",
|
||||||
|
"modify the tree print out to show the dots and dashes \n",
|
||||||
|
"take a user input in morse code, and use the binary tree to decode the message one character at a time\n",
|
||||||
|
"translate the dot dash signals into other forms of pulsations: LED light, sound to be sent out via radio signal, ?FSK (written on the code memo)\n",
|
||||||
|
"would be nice to emphasize the traversal aspect, can it be displayed / heard - traversing to the dot! traversing to the dash! make it procedural -> maybe console can be helpful "
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "6ca5a800-4180-43bc-9a1c-ba260b9f207a",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"# reference project\n",
|
||||||
|
"# https://microbit-micropython.readthedocs.io/en/latest/tutorials/radio.html\n",
|
||||||
|
"# https://new.pythonforengineers.com/blog/audio-and-digital-signal-processingdsp-in-python/"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"kernelspec": {
|
||||||
|
"display_name": "Python 3 (ipykernel)",
|
||||||
|
"language": "python",
|
||||||
|
"name": "python3"
|
||||||
|
},
|
||||||
|
"language_info": {
|
||||||
|
"codemirror_mode": {
|
||||||
|
"name": "ipython",
|
||||||
|
"version": 3
|
||||||
|
},
|
||||||
|
"file_extension": ".py",
|
||||||
|
"mimetype": "text/x-python",
|
||||||
|
"name": "python",
|
||||||
|
"nbconvert_exporter": "python",
|
||||||
|
"pygments_lexer": "ipython3",
|
||||||
|
"version": "3.9.7"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 5
|
||||||
|
}
|
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"cells": [],
|
||||||
|
"metadata": {},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 5
|
||||||
|
}
|
@ -0,0 +1,53 @@
|
|||||||
|
{
|
||||||
|
"cells": [
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "d620c21c-89d5-4b37-888f-79212671d7db",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"# a raspberry orange tree"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "343265dc-49bd-4220-96aa-3ed2fbd1a54e",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"# https://www.reddit.com/r/aldi/comments/kqxzuc/the_raspberry_oranges_are_wonderful/"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "f519c19c-03f2-4332-be12-fd3beab81cb7",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"# pigment is shared between the raspberry species and the raspberry orange species"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"kernelspec": {
|
||||||
|
"display_name": "Python 3 (ipykernel)",
|
||||||
|
"language": "python",
|
||||||
|
"name": "python3"
|
||||||
|
},
|
||||||
|
"language_info": {
|
||||||
|
"codemirror_mode": {
|
||||||
|
"name": "ipython",
|
||||||
|
"version": 3
|
||||||
|
},
|
||||||
|
"file_extension": ".py",
|
||||||
|
"mimetype": "text/x-python",
|
||||||
|
"name": "python",
|
||||||
|
"nbconvert_exporter": "python",
|
||||||
|
"pygments_lexer": "ipython3",
|
||||||
|
"version": "3.9.7"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 5
|
||||||
|
}
|
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"cells": [],
|
||||||
|
"metadata": {},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 5
|
||||||
|
}
|
@ -0,0 +1,186 @@
|
|||||||
|
{
|
||||||
|
"cells": [
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 1,
|
||||||
|
"id": "2363b275-a2e8-429b-94f2-e645178b38f1",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"\"\"\"Python3 program to demonstrate insert\n",
|
||||||
|
"operation in binary search tree \"\"\"\n",
|
||||||
|
"\n",
|
||||||
|
"# A Binary Tree Node\n",
|
||||||
|
"# Utility function to create a\n",
|
||||||
|
"# new tree node\n",
|
||||||
|
"class newNode:\n",
|
||||||
|
"\n",
|
||||||
|
" # Constructor to create a newNode\n",
|
||||||
|
" def __init__(self, data):\n",
|
||||||
|
" self.key= data\n",
|
||||||
|
" self.left = None\n",
|
||||||
|
" self.right = self.parent = None\n",
|
||||||
|
"\n",
|
||||||
|
"# A utility function to insert a new\n",
|
||||||
|
"# Node with given key in BST\n",
|
||||||
|
"def insert(root, key):\n",
|
||||||
|
"\n",
|
||||||
|
" # Create a new Node containing\n",
|
||||||
|
" # the new element\n",
|
||||||
|
" newnode = newNode(key)\n",
|
||||||
|
"\n",
|
||||||
|
" # Pointer to start traversing from root\n",
|
||||||
|
" # and traverses downward path to search\n",
|
||||||
|
" # where the new node to be inserted\n",
|
||||||
|
" x = root\n",
|
||||||
|
"\n",
|
||||||
|
" # Pointer y maintains the trailing\n",
|
||||||
|
" # pointer of x\n",
|
||||||
|
" y = None\n",
|
||||||
|
"\n",
|
||||||
|
" while (x != None):\n",
|
||||||
|
" y = x\n",
|
||||||
|
" if (key < x.key):\n",
|
||||||
|
" x = x.left\n",
|
||||||
|
" else:\n",
|
||||||
|
" x = x.right\n",
|
||||||
|
" \n",
|
||||||
|
" # If the root is None i.e the tree is\n",
|
||||||
|
" # empty. The new node is the root node\n",
|
||||||
|
" if (y == None):\n",
|
||||||
|
" y = newnode\n",
|
||||||
|
"\n",
|
||||||
|
" # If the new key is less then the leaf node key\n",
|
||||||
|
" # Assign the new node to be its left child\n",
|
||||||
|
" elif (key < y.key):\n",
|
||||||
|
" y.left = newnode\n",
|
||||||
|
"\n",
|
||||||
|
" # else assign the new node its\n",
|
||||||
|
" # right child\n",
|
||||||
|
" else:\n",
|
||||||
|
" y.right = newnode\n",
|
||||||
|
"\n",
|
||||||
|
" # Returns the pointer where the\n",
|
||||||
|
" # new node is inserted\n",
|
||||||
|
" return y\n",
|
||||||
|
"\n",
|
||||||
|
"# A utility function to do inorder\n",
|
||||||
|
"# traversal of BST\n",
|
||||||
|
"def Inorder(root) :\n",
|
||||||
|
"\n",
|
||||||
|
" if (root == None) :\n",
|
||||||
|
" return\n",
|
||||||
|
" else:\n",
|
||||||
|
" Inorder(root.left)\n",
|
||||||
|
" print( root.key, end = \" \" )\n",
|
||||||
|
" Inorder(root.right)\n",
|
||||||
|
"\n",
|
||||||
|
"#Driver Code\n",
|
||||||
|
"if __name__ == '__main__':\n",
|
||||||
|
"\n",
|
||||||
|
" root = None\n",
|
||||||
|
" root = insert(root, \"m\")\n",
|
||||||
|
" insert(root, \"n\")\n",
|
||||||
|
" insert(root, \"l\")\n",
|
||||||
|
" insert(root, \"p\")\n",
|
||||||
|
" insert(root, \"q\")\n",
|
||||||
|
" insert(root, \"a\")\n",
|
||||||
|
" insert(root, \"b\")\n",
|
||||||
|
"\n",
|
||||||
|
"\n",
|
||||||
|
" # Pr inorder traversal of the BST\n",
|
||||||
|
"\n",
|
||||||
|
"\n",
|
||||||
|
"# This code is contributed by\n",
|
||||||
|
"# SHUBHAMSINGH10"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 3,
|
||||||
|
"id": "921f4017-3f1f-4085-8da8-cc850fbd4c6e",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"\n",
|
||||||
|
" q\n",
|
||||||
|
"\n",
|
||||||
|
" p\n",
|
||||||
|
"\n",
|
||||||
|
" n\n",
|
||||||
|
"\n",
|
||||||
|
"m\n",
|
||||||
|
"\n",
|
||||||
|
" l\n",
|
||||||
|
"\n",
|
||||||
|
" b\n",
|
||||||
|
"\n",
|
||||||
|
" a\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"# print binary tree in 2D copied from sample program\n",
|
||||||
|
"COUNT = [10]\n",
|
||||||
|
"def print2DUtil(root, space) :\n",
|
||||||
|
"\n",
|
||||||
|
" # Base case\n",
|
||||||
|
" if (root == None) :\n",
|
||||||
|
" return\n",
|
||||||
|
"\n",
|
||||||
|
" # Increase distance between levels\n",
|
||||||
|
" space += COUNT[0]\n",
|
||||||
|
"\n",
|
||||||
|
" # Process right child first\n",
|
||||||
|
" print2DUtil(root.right, space)\n",
|
||||||
|
"\n",
|
||||||
|
" # Print current node after space\n",
|
||||||
|
" # count\n",
|
||||||
|
" print()\n",
|
||||||
|
" for i in range(COUNT[0], space):\n",
|
||||||
|
" print(end = \" \")\n",
|
||||||
|
" print(root.key)\n",
|
||||||
|
"\n",
|
||||||
|
" # Process left child\n",
|
||||||
|
" print2DUtil(root.left, space)\n",
|
||||||
|
"\n",
|
||||||
|
"# Wrapper over print2DUtil()\n",
|
||||||
|
"def print2D(root) :\n",
|
||||||
|
" \n",
|
||||||
|
" # space=[0]\n",
|
||||||
|
" # Pass initial space count as 0\n",
|
||||||
|
" print2DUtil(root, 0)\n",
|
||||||
|
"\n",
|
||||||
|
"# Driver Code\n",
|
||||||
|
"if __name__ == '__main__':\n",
|
||||||
|
"\n",
|
||||||
|
" \n",
|
||||||
|
" print2D(root)"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"kernelspec": {
|
||||||
|
"display_name": "Python 3 (ipykernel)",
|
||||||
|
"language": "python",
|
||||||
|
"name": "python3"
|
||||||
|
},
|
||||||
|
"language_info": {
|
||||||
|
"codemirror_mode": {
|
||||||
|
"name": "ipython",
|
||||||
|
"version": 3
|
||||||
|
},
|
||||||
|
"file_extension": ".py",
|
||||||
|
"mimetype": "text/x-python",
|
||||||
|
"name": "python",
|
||||||
|
"nbconvert_exporter": "python",
|
||||||
|
"pygments_lexer": "ipython3",
|
||||||
|
"version": "3.9.7"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 5
|
||||||
|
}
|
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"cells": [],
|
||||||
|
"metadata": {},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 5
|
||||||
|
}
|
@ -0,0 +1,49 @@
|
|||||||
|
{
|
||||||
|
"cells": [
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 1,
|
||||||
|
"id": "1cb5571e-af37-47eb-ba2d-5c10c87fbb9e",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"class tridentLeaf:\n",
|
||||||
|
" def __init__(self,something,somethingelse):\n",
|
||||||
|
" self.leftProng = None\n",
|
||||||
|
" self.middleProng = None\n",
|
||||||
|
" self.rightProng = None\n",
|
||||||
|
" self.something = something\n",
|
||||||
|
" self.somethingelse = somethingelse"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "6c797c5b-e7e0-432f-9a85-27e7c6e1bdc9",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"kernelspec": {
|
||||||
|
"display_name": "Python 3 (ipykernel)",
|
||||||
|
"language": "python",
|
||||||
|
"name": "python3"
|
||||||
|
},
|
||||||
|
"language_info": {
|
||||||
|
"codemirror_mode": {
|
||||||
|
"name": "ipython",
|
||||||
|
"version": 3
|
||||||
|
},
|
||||||
|
"file_extension": ".py",
|
||||||
|
"mimetype": "text/x-python",
|
||||||
|
"name": "python",
|
||||||
|
"nbconvert_exporter": "python",
|
||||||
|
"pygments_lexer": "ipython3",
|
||||||
|
"version": "3.9.7"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 5
|
||||||
|
}
|
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"cells": [],
|
||||||
|
"metadata": {},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 5
|
||||||
|
}
|
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"cells": [],
|
||||||
|
"metadata": {},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 5
|
||||||
|
}
|
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"cells": [],
|
||||||
|
"metadata": {},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 5
|
||||||
|
}
|
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"cells": [],
|
||||||
|
"metadata": {},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 5
|
||||||
|
}
|
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"cells": [],
|
||||||
|
"metadata": {},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 5
|
||||||
|
}
|
After Width: | Height: | Size: 57 KiB |
@ -0,0 +1,12 @@
|
|||||||
|
# ABOUT
|
||||||
|
A series of programs that builds on the tree structure, an abstract data
|
||||||
|
type used for presenting, storing and searching information
|
||||||
|
|
||||||
|
# VALUE IN MEDIA ARCHAEOLOGY
|
||||||
|
# VALUE IN CRITICAL STUDIES
|
||||||
|
# FORMAT
|
||||||
|
Textual outputs are stored as txt files, and image outputs are stored as image files. The program process is stored in Jupyter Notebooks.
|
||||||
|
# WHERE IS THIS FORKED FROM
|
||||||
|
# FORK YOUR OWN
|
||||||
|
|
||||||
|
|
@ -0,0 +1,79 @@
|
|||||||
|
{
|
||||||
|
"cells": [
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "666a35e1-435d-4555-8193-9258ff568e21",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"class letterLeaf:\n",
|
||||||
|
" def __init__(self,question):\n",
|
||||||
|
" self.yes = None\n",
|
||||||
|
" self.no = None\n",
|
||||||
|
" self.question = question\n"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "254b714a-2504-4cc0-9a78-21d406ddbb2f",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"# tree traversals, here to print stuff \n",
|
||||||
|
"def inorder(treeName):\n",
|
||||||
|
" if treeName:\n",
|
||||||
|
" inorder(treeName.yes)\n",
|
||||||
|
" print(treeName.question)\n",
|
||||||
|
" inorder(treeName.no)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "e8512457-7944-4604-92c7-29f90ab6c3db",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"# interactive user input utility \n",
|
||||||
|
"def saysYes(ques):\n",
|
||||||
|
" while True:\n",
|
||||||
|
" ans = input(ques)\n",
|
||||||
|
" ans = ans[0:1].lower()\n",
|
||||||
|
" if ans == 'y': return True\n",
|
||||||
|
" else : return False"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "8415d1d2-211a-4e82-b331-85527e8c1510",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"reference\n",
|
||||||
|
"https://web.stonehill.edu/compsci/CS211/Assignmenta%202015/TreeAssignment.pdf"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"kernelspec": {
|
||||||
|
"display_name": "Python 3 (ipykernel)",
|
||||||
|
"language": "python",
|
||||||
|
"name": "python3"
|
||||||
|
},
|
||||||
|
"language_info": {
|
||||||
|
"codemirror_mode": {
|
||||||
|
"name": "ipython",
|
||||||
|
"version": 3
|
||||||
|
},
|
||||||
|
"file_extension": ".py",
|
||||||
|
"mimetype": "text/x-python",
|
||||||
|
"name": "python",
|
||||||
|
"nbconvert_exporter": "python",
|
||||||
|
"pygments_lexer": "ipython3",
|
||||||
|
"version": "3.9.7"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 5
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
{
|
||||||
|
"cells": [
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "b8bb6f10-0461-4fb9-9f36-9b64ae33405c",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"# a genetic tree"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"kernelspec": {
|
||||||
|
"display_name": "Python 3 (ipykernel)",
|
||||||
|
"language": "python",
|
||||||
|
"name": "python3"
|
||||||
|
},
|
||||||
|
"language_info": {
|
||||||
|
"codemirror_mode": {
|
||||||
|
"name": "ipython",
|
||||||
|
"version": 3
|
||||||
|
},
|
||||||
|
"file_extension": ".py",
|
||||||
|
"mimetype": "text/x-python",
|
||||||
|
"name": "python",
|
||||||
|
"nbconvert_exporter": "python",
|
||||||
|
"pygments_lexer": "ipython3",
|
||||||
|
"version": "3.9.7"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 5
|
||||||
|
}
|
@ -0,0 +1,90 @@
|
|||||||
|
import time
|
||||||
|
fruit_list = ["apricot","blood orange","currant","durian","egg fruit","fig","guava",
|
||||||
|
"hawthorne","jujube","kiwi","lychee","mandarin","nectarine","olive","persimmon","quandong","rambutan","star fruit",
|
||||||
|
"tangor","ugli fruit","vanilla","water chestnut","ximenia","yuzu","zhe"]
|
||||||
|
|
||||||
|
class letterLeaf:
|
||||||
|
def __init__(self,letter,wordFruit):
|
||||||
|
self.leftAlphabet = None
|
||||||
|
self.rightAlphabet = None
|
||||||
|
self.letter = letter
|
||||||
|
self.wordFruit = wordFruit
|
||||||
|
|
||||||
|
COUNT = [10]
|
||||||
|
|
||||||
|
def print2DUtil_flat(root, space,growth_rate):
|
||||||
|
if (root == None) :
|
||||||
|
return
|
||||||
|
|
||||||
|
space += COUNT[0]
|
||||||
|
print2DUtil_flat(root.rightAlphabet, space,growth_rate)
|
||||||
|
|
||||||
|
print()
|
||||||
|
|
||||||
|
for i in range(COUNT[0], space):
|
||||||
|
print(end = " ")
|
||||||
|
|
||||||
|
print(root.letter)
|
||||||
|
|
||||||
|
for i in range(COUNT[0], space):
|
||||||
|
print(end = " ")
|
||||||
|
|
||||||
|
print(root.wordFruit)
|
||||||
|
time.sleep(growth_rate)
|
||||||
|
|
||||||
|
print2DUtil_flat(root.leftAlphabet, space,growth_rate)
|
||||||
|
|
||||||
|
def print2D(root, growth_rate):
|
||||||
|
print("here is a tree that's laying on the ground: ")
|
||||||
|
print2DUtil_flat(root, 0, growth_rate)
|
||||||
|
|
||||||
|
def grepFirstLetter(word):
|
||||||
|
firstLetter = word[0]
|
||||||
|
return firstLetter
|
||||||
|
|
||||||
|
def insertLeaf(root,wordFruit):
|
||||||
|
letter = grepFirstLetter(wordFruit)
|
||||||
|
newleaf = letterLeaf(letter,wordFruit)
|
||||||
|
x = root
|
||||||
|
y = None
|
||||||
|
|
||||||
|
while (x != None):
|
||||||
|
y = x
|
||||||
|
if (letter < x.letter):
|
||||||
|
x = x.leftAlphabet
|
||||||
|
else:
|
||||||
|
x = x.rightAlphabet
|
||||||
|
|
||||||
|
if (y == None):
|
||||||
|
y = newleaf
|
||||||
|
|
||||||
|
elif (letter < y.letter):
|
||||||
|
y.leftAlphabet = newleaf
|
||||||
|
|
||||||
|
else:
|
||||||
|
y.rightAlphabet = newleaf
|
||||||
|
|
||||||
|
return y
|
||||||
|
|
||||||
|
import random
|
||||||
|
|
||||||
|
root = None
|
||||||
|
|
||||||
|
random_fruit = random.choice(fruit_list)
|
||||||
|
root = insertLeaf(root, random_fruit)
|
||||||
|
fruit_list.remove(random_fruit)
|
||||||
|
len_list = (len(fruit_list))
|
||||||
|
|
||||||
|
while len_list > 0:
|
||||||
|
random_fruit = random.choice(fruit_list)
|
||||||
|
insertLeaf(root,random_fruit)
|
||||||
|
fruit_list.remove(random_fruit)
|
||||||
|
len_list -= 1
|
||||||
|
|
||||||
|
|
||||||
|
def ask_input():
|
||||||
|
growth_rate = int(input("Enter growth rate value for tree in seconds: "))
|
||||||
|
return growth_rate
|
||||||
|
|
||||||
|
growth_rate = ask_input()
|
||||||
|
print2D(root, growth_rate)
|
@ -0,0 +1,26 @@
|
|||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||||
|
<link rel="stylesheet" href="https://pyscript.net/alpha/pyscript.css" />
|
||||||
|
<script defer src="https://pyscript.net/alpha/pyscript.js"></script>
|
||||||
|
|
||||||
|
<link rel="stylesheet" type="text/css" href="style.css" />
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<title> A Letter Tree </title>
|
||||||
|
|
||||||
|
|
||||||
|
<h1> A Letter Tree </h1>
|
||||||
|
<body>
|
||||||
|
<div id="console-embed"></div>
|
||||||
|
|
||||||
|
<!-- adjust trinket iframe style> <-->
|
||||||
|
<iframe src="https://trinket.io/embed/python3/3e17f35d95?start=result" width="100%" height="600" frameborder="0" marginwidth="0" marginheight="0" allowfullscreen></iframe>
|
||||||
|
<div>Layout created by recursive process:
|
||||||
|
<img src="fig_18_1.png">
|
||||||
|
Source: Metamagical Themas, pt4, Structure and strangeness.
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -0,0 +1,111 @@
|
|||||||
|
from cgitb import html
|
||||||
|
import time
|
||||||
|
|
||||||
|
fruit_list = ["apricot","blood orange","currant","durian","egg fruit","fig","guava",
|
||||||
|
"hawthorne","jujube","kiwi","lychee","mandarin","nectarine","olive","persimmon","quandong","rambutan","star fruit",
|
||||||
|
"tangor","ugli fruit","vanilla","water chestnut","ximenia","yuzu","zhe"]
|
||||||
|
|
||||||
|
class letterLeaf:
|
||||||
|
def __init__(self,letter,wordFruit):
|
||||||
|
self.leftAlphabet = None
|
||||||
|
self.rightAlphabet = None
|
||||||
|
self.letter = letter
|
||||||
|
self.wordFruit = wordFruit
|
||||||
|
|
||||||
|
COUNT = [3]
|
||||||
|
empty_string = " "
|
||||||
|
|
||||||
|
def print2DUtil_flat(root, space, growth_rate, html_file):
|
||||||
|
if (root == None) :
|
||||||
|
return
|
||||||
|
|
||||||
|
space += COUNT[0]
|
||||||
|
print2DUtil_flat(root.rightAlphabet, space,growth_rate, html_file)
|
||||||
|
|
||||||
|
|
||||||
|
html_file.write("<span>")
|
||||||
|
#for i in range(COUNT[0], space):
|
||||||
|
# html_file.write(" ")
|
||||||
|
|
||||||
|
html_file.write(root.letter + "<br>")
|
||||||
|
html_file.write("</span>")
|
||||||
|
|
||||||
|
html_file.write("\n")
|
||||||
|
|
||||||
|
|
||||||
|
html_file.write(root.wordFruit + "<br>")
|
||||||
|
html_file.write("\n")
|
||||||
|
|
||||||
|
print2DUtil_flat(root.leftAlphabet, space, growth_rate, html_file)
|
||||||
|
|
||||||
|
def print2D(root, growth_rate, html_file):
|
||||||
|
print("here is a tree that's laying on the ground: ")
|
||||||
|
print2DUtil_flat(root, 0, growth_rate, html_file)
|
||||||
|
|
||||||
|
def grepFirstLetter(word):
|
||||||
|
firstLetter = word[0]
|
||||||
|
return firstLetter
|
||||||
|
|
||||||
|
def insertLeaf(root,wordFruit):
|
||||||
|
letter = grepFirstLetter(wordFruit)
|
||||||
|
newleaf = letterLeaf(letter,wordFruit)
|
||||||
|
x = root
|
||||||
|
y = None
|
||||||
|
|
||||||
|
while (x != None):
|
||||||
|
y = x
|
||||||
|
if (letter < x.letter):
|
||||||
|
x = x.leftAlphabet
|
||||||
|
else:
|
||||||
|
x = x.rightAlphabet
|
||||||
|
|
||||||
|
if (y == None):
|
||||||
|
y = newleaf
|
||||||
|
|
||||||
|
elif (letter < y.letter):
|
||||||
|
y.leftAlphabet = newleaf
|
||||||
|
|
||||||
|
else:
|
||||||
|
y.rightAlphabet = newleaf
|
||||||
|
|
||||||
|
return y
|
||||||
|
|
||||||
|
import random
|
||||||
|
|
||||||
|
root = None
|
||||||
|
|
||||||
|
random_fruit = random.choice(fruit_list)
|
||||||
|
root = insertLeaf(root, random_fruit)
|
||||||
|
fruit_list.remove(random_fruit)
|
||||||
|
len_list = (len(fruit_list))
|
||||||
|
|
||||||
|
while len_list > 0:
|
||||||
|
random_fruit = random.choice(fruit_list)
|
||||||
|
insertLeaf(root,random_fruit)
|
||||||
|
fruit_list.remove(random_fruit)
|
||||||
|
len_list -= 1
|
||||||
|
|
||||||
|
|
||||||
|
def ask_input():
|
||||||
|
growth_rate = int(input("Enter growth rate value for tree in seconds: "))
|
||||||
|
return growth_rate
|
||||||
|
|
||||||
|
growth_rate = ask_input()
|
||||||
|
|
||||||
|
html_file = open("a_letter_tree_web.html","w")
|
||||||
|
|
||||||
|
html_file.write("<html>\n<head>\n")
|
||||||
|
html_file.write("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />\n")
|
||||||
|
html_file.write("<link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\" />\n")
|
||||||
|
html_file.write("</head>\n")
|
||||||
|
html_file.write("<body>\n")
|
||||||
|
html_file.write("<title> A Letter Tree </title>\n")
|
||||||
|
html_file.write("<h1> A Letter Tree </h1>")
|
||||||
|
|
||||||
|
print2D(root, growth_rate, html_file)
|
||||||
|
|
||||||
|
html_file.write("\n</body>\n</html>")
|
||||||
|
html_file.close()
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,383 @@
|
|||||||
|
{
|
||||||
|
"cells": [
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "59b5e56e-137c-4c72-8832-3fb7e625fddc",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"# a longan tree\n",
|
||||||
|
"# 龙眼树"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "1d3d5765-21b5-4022-8fb6-995feadbd000",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"## what is longan?\n",
|
||||||
|
"Dimocarpus longan, commonly known as the longan, is a tropical tree species that produces edible fruit. It is one of the better-known tropical members of the soapberry family Sapindaceae,to which the lychee and rambutan also belong. The fruit of the longan is similar to that of the lychee, but less aromatic in taste."
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "8bd7458b-bbb1-4977-9f78-a4f8f2e93985",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"### a photo of a longan tree with fruits\n",
|
||||||
|
"from reddit post https://www.reddit.com/r/gardening/comments/8cfh6n/our_glorious_longan_tree/"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 1,
|
||||||
|
"id": "39a00b5f-45ca-4356-ad0e-b2cef2593ef1",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"data": {
|
||||||
|
"text/html": [
|
||||||
|
"<img src=\"images/longan_tree.jpg\" width=\"400\" height=\"400\"/>"
|
||||||
|
],
|
||||||
|
"text/plain": [
|
||||||
|
"<IPython.core.display.Image object>"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"execution_count": 1,
|
||||||
|
"metadata": {},
|
||||||
|
"output_type": "execute_result"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"from IPython.display import Image\n",
|
||||||
|
"url_tree = \"images/longan_tree.jpg\"\n",
|
||||||
|
"Image(url= url_tree, width=400, height=400)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "547e4b39-856f-4374-a23a-b95917817749",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"## what is the soapberry family Sapindaceae?\n",
|
||||||
|
"The Sapindaceae are a family of flowering plants in the order Sapindales known as the soapberry family. \n"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "9a0050aa-eabb-4407-971e-abd89f9ddb17",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"### why is knowing the soapberry family important for the longan tree"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "68ba1fba-d0f0-4e6f-952b-07ae19262df8",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"As we know the longan tree is one tree species under the soapberry family, we can track the other tree species relevant to the longan tree. The lychee tree, the rambutan tree, and the longan tree are closely related to each other. "
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "0af3e49f-f417-4779-afc8-9932be9539f5",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"This is written in early spring, and longan fruits are harvested during the summer. In villages in Southern China, harvesting longan fruits \"摘龙眼\"is a fun summer activity. "
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "7ba8cd22-532f-424c-8c57-96990a8903fd",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"Longan also means \"dragon eye\". The fruit is round, resembling an eyeball of a dragon. There is also the \"phoenix eye\"(凤眼),referring to eyes that has a long-ish shape and tilts upwards. "
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "3f133efd-1adf-40f0-acb6-24fbff03bebb",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"In a gender binary context, suppose there is a pair of twins that's a boy and a girl. In Chinese such pair of twins is refered to as \"dragon and phoenix twin\"(龙凤胎)。Suppose the girl has the \"phonenix eyes\"(凤眼), then would the boy eat loads of \"dragon eyes\"(龙眼)?!\n",
|
||||||
|
"在性别二元对立的语境下,有一对龙凤胎,女孩有一双凤眼,那男孩岂不是有一双龙眼?!"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 23,
|
||||||
|
"id": "23f11815-0327-4027-8e4a-6004595e9525",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"eyes_l = [\"⊙\",\"ಠ\",\"ಡ\",\"⚆\",\n",
|
||||||
|
" \"✪\",\"◙\",\"*\",\"°\",\n",
|
||||||
|
" \"☉\",\"⚈\",\"๏\",\"◔\",\n",
|
||||||
|
" \"◉\",\"ʘ\",\"Θ\",\"❍\",\n",
|
||||||
|
" \"●\",\"ᓂ\",\"ᓀ\",\"•͈\",\n",
|
||||||
|
" ]"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "e9181f99-311b-4788-bba1-3781b62dc7f8",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"## dragon eyes of various affects\n",
|
||||||
|
"呆萌的龙眼,迟疑的龙眼,左顾右盼的龙眼,闪烁其辞的龙眼。\n",
|
||||||
|
"被踩扁的龙眼,爆了浆的龙眼,剥开皮的龙眼,被掏空的龙眼。"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 24,
|
||||||
|
"id": "f74f4027-9305-4862-adb9-3bd46bae37ad",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"# build a tree from eyes_l\n",
|
||||||
|
"# can try a binary tree structure\n",
|
||||||
|
"# however, a longan tree cannot be arbitrarily defined as using\n",
|
||||||
|
"# the bst structure\n",
|
||||||
|
"# are there other tree branching structures to try? "
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 25,
|
||||||
|
"id": "35a275f8-71d4-4354-b019-befc9650c042",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"# starting from a yard of trees: longan, lychee and rombutan "
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 26,
|
||||||
|
"id": "fe8cc549-0ffe-4d55-afb3-a49605fca2c1",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"soapberry forest\n",
|
||||||
|
"├── longan\n",
|
||||||
|
"├── lychee\n",
|
||||||
|
"└── rombutan\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"from anytree import Node, RenderTree\n",
|
||||||
|
"# build tree\n",
|
||||||
|
"soapberryForest = Node(\"soapberry forest\")\n",
|
||||||
|
"longan = Node(\"longan\", parent=soapberryForest)\n",
|
||||||
|
"lychee = Node(\"lychee\", parent=soapberryForest)\n",
|
||||||
|
"rombutan = Node(\"rombutan\", parent=soapberryForest)\n",
|
||||||
|
"\n",
|
||||||
|
"# print tree\n",
|
||||||
|
"for pre, fill, node in RenderTree(soapberryForest):\n",
|
||||||
|
"\tprint(\"%s%s\" %(pre,node.name))"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 27,
|
||||||
|
"id": "a651378f-02e3-4da4-8510-3754af471cc2",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"# bst tree template \n",
|
||||||
|
"\"\"\"Python3 program to demonstrate insert\n",
|
||||||
|
"operation in binary search tree \"\"\"\n",
|
||||||
|
"\n",
|
||||||
|
"# A Binary Tree Node\n",
|
||||||
|
"# Utility function to create a\n",
|
||||||
|
"# new tree node\n",
|
||||||
|
"class newNode:\n",
|
||||||
|
"\n",
|
||||||
|
" # Constructor to create a newNode\n",
|
||||||
|
" def __init__(self, data):\n",
|
||||||
|
" self.key= data\n",
|
||||||
|
" self.left = None\n",
|
||||||
|
" self.right = self.parent = None\n",
|
||||||
|
"\n",
|
||||||
|
"# A utility function to insert a new\n",
|
||||||
|
"# Node with given key in BST\n",
|
||||||
|
"def insert(root, key):\n",
|
||||||
|
"\n",
|
||||||
|
" # Create a new Node containing\n",
|
||||||
|
" # the new element\n",
|
||||||
|
" newnode = newNode(key)\n",
|
||||||
|
"\n",
|
||||||
|
" # Pointer to start traversing from root\n",
|
||||||
|
" # and traverses downward path to search\n",
|
||||||
|
" # where the new node to be inserted\n",
|
||||||
|
" x = root\n",
|
||||||
|
"\n",
|
||||||
|
" # Pointer y maintains the trailing\n",
|
||||||
|
" # pointer of x\n",
|
||||||
|
" y = None\n",
|
||||||
|
"\n",
|
||||||
|
" while (x != None):\n",
|
||||||
|
" y = x\n",
|
||||||
|
" if (key < x.key):\n",
|
||||||
|
" x = x.left\n",
|
||||||
|
" else:\n",
|
||||||
|
" x = x.right\n",
|
||||||
|
" \n",
|
||||||
|
" # If the root is None i.e the tree is\n",
|
||||||
|
" # empty. The new node is the root node\n",
|
||||||
|
" if (y == None):\n",
|
||||||
|
" y = newnode\n",
|
||||||
|
"\n",
|
||||||
|
" # If the new key is less then the leaf node key\n",
|
||||||
|
" # Assign the new node to be its left child\n",
|
||||||
|
" elif (key < y.key):\n",
|
||||||
|
" y.left = newnode\n",
|
||||||
|
"\n",
|
||||||
|
" # else assign the new node its\n",
|
||||||
|
" # right child\n",
|
||||||
|
" else:\n",
|
||||||
|
" y.right = newnode\n",
|
||||||
|
"\n",
|
||||||
|
" # Returns the pointer where the\n",
|
||||||
|
" # new node is inserted\n",
|
||||||
|
" return y\n",
|
||||||
|
"\n",
|
||||||
|
"#Driver Code\n",
|
||||||
|
"if __name__ == '__main__':\n",
|
||||||
|
"\n",
|
||||||
|
" root = None\n",
|
||||||
|
" root = insert(root, \"longan tree\")\n",
|
||||||
|
" for eye in eyes_l:\n",
|
||||||
|
" insert(root,eye)\n",
|
||||||
|
"\n"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 28,
|
||||||
|
"id": "ef3979c3-7da9-4bb3-a691-4a210da308cb",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"\n",
|
||||||
|
" ❍\n",
|
||||||
|
"\n",
|
||||||
|
" ✪\n",
|
||||||
|
"\n",
|
||||||
|
" ⚈\n",
|
||||||
|
"\n",
|
||||||
|
" ⚆\n",
|
||||||
|
"\n",
|
||||||
|
" ☉\n",
|
||||||
|
"\n",
|
||||||
|
" ◙\n",
|
||||||
|
"\n",
|
||||||
|
" ◔\n",
|
||||||
|
"\n",
|
||||||
|
" ●\n",
|
||||||
|
"\n",
|
||||||
|
" ◉\n",
|
||||||
|
"\n",
|
||||||
|
" ⊙\n",
|
||||||
|
"\n",
|
||||||
|
" •͈\n",
|
||||||
|
"\n",
|
||||||
|
" ᓂ\n",
|
||||||
|
"\n",
|
||||||
|
" ᓀ\n",
|
||||||
|
"\n",
|
||||||
|
" ๏\n",
|
||||||
|
"\n",
|
||||||
|
" ಡ\n",
|
||||||
|
"\n",
|
||||||
|
" ಠ\n",
|
||||||
|
"\n",
|
||||||
|
" Θ\n",
|
||||||
|
"\n",
|
||||||
|
" ʘ\n",
|
||||||
|
"\n",
|
||||||
|
" °\n",
|
||||||
|
"\n",
|
||||||
|
"longan tree\n",
|
||||||
|
"\n",
|
||||||
|
" *\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"COUNT = [10]\n",
|
||||||
|
"def print2DUtil(root, space) :\n",
|
||||||
|
"\n",
|
||||||
|
" # Base case\n",
|
||||||
|
" if (root == None) :\n",
|
||||||
|
" return\n",
|
||||||
|
"\n",
|
||||||
|
" # Increase distance between levels\n",
|
||||||
|
" space += COUNT[0]\n",
|
||||||
|
"\n",
|
||||||
|
" # Process right child first\n",
|
||||||
|
" print2DUtil(root.right, space)\n",
|
||||||
|
"\n",
|
||||||
|
" # Print current node after space\n",
|
||||||
|
" # count\n",
|
||||||
|
" print()\n",
|
||||||
|
" for i in range(COUNT[0], space):\n",
|
||||||
|
" print(end = \" \")\n",
|
||||||
|
" print(root.key)\n",
|
||||||
|
"\n",
|
||||||
|
" # Process left child\n",
|
||||||
|
" print2DUtil(root.left, space)\n",
|
||||||
|
"\n",
|
||||||
|
"# Wrapper over print2DUtil()\n",
|
||||||
|
"def print2D(root) :\n",
|
||||||
|
" \n",
|
||||||
|
" # space=[0]\n",
|
||||||
|
" # Pass initial space count as 0\n",
|
||||||
|
" print2DUtil(root, 0)\n",
|
||||||
|
"\n",
|
||||||
|
"# Driver Code\n",
|
||||||
|
"if __name__ == '__main__':\n",
|
||||||
|
"\n",
|
||||||
|
" \n",
|
||||||
|
" print2D(root)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "d8d8b5fa-49cf-47e5-8c69-a0285b286030",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"a pun, a poem, a puoem. "
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"kernelspec": {
|
||||||
|
"display_name": "Python 3 (ipykernel)",
|
||||||
|
"language": "python",
|
||||||
|
"name": "python3"
|
||||||
|
},
|
||||||
|
"language_info": {
|
||||||
|
"codemirror_mode": {
|
||||||
|
"name": "ipython",
|
||||||
|
"version": 3
|
||||||
|
},
|
||||||
|
"file_extension": ".py",
|
||||||
|
"mimetype": "text/x-python",
|
||||||
|
"name": "python",
|
||||||
|
"nbconvert_exporter": "python",
|
||||||
|
"pygments_lexer": "ipython3",
|
||||||
|
"version": "3.9.7"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 5
|
||||||
|
}
|
@ -0,0 +1,49 @@
|
|||||||
|
{
|
||||||
|
"cells": [
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "23070ca4-55cc-4a58-97d5-cb2fcb9c30a2",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"# todo \n",
|
||||||
|
"modify the tree print out to show the dots and dashes \n",
|
||||||
|
"take a user input in morse code, and use the binary tree to decode the message one character at a time\n",
|
||||||
|
"translate the dot dash signals into other forms of pulsations: LED light, sound to be sent out via radio signal, ?FSK (written on the code memo)\n",
|
||||||
|
"would be nice to emphasize the traversal aspect, can it be displayed / heard - traversing to the dot! traversing to the dash! make it procedural -> maybe console can be helpful "
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "6ca5a800-4180-43bc-9a1c-ba260b9f207a",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"# reference project\n",
|
||||||
|
"# https://microbit-micropython.readthedocs.io/en/latest/tutorials/radio.html\n",
|
||||||
|
"# https://new.pythonforengineers.com/blog/audio-and-digital-signal-processingdsp-in-python/"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"kernelspec": {
|
||||||
|
"display_name": "Python 3 (ipykernel)",
|
||||||
|
"language": "python",
|
||||||
|
"name": "python3"
|
||||||
|
},
|
||||||
|
"language_info": {
|
||||||
|
"codemirror_mode": {
|
||||||
|
"name": "ipython",
|
||||||
|
"version": 3
|
||||||
|
},
|
||||||
|
"file_extension": ".py",
|
||||||
|
"mimetype": "text/x-python",
|
||||||
|
"name": "python",
|
||||||
|
"nbconvert_exporter": "python",
|
||||||
|
"pygments_lexer": "ipython3",
|
||||||
|
"version": "3.9.7"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 5
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
{
|
||||||
|
"cells": [
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "2b1fd5e7-4734-46ad-b57f-8c05acd86338",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"kernelspec": {
|
||||||
|
"display_name": "Python 3 (ipykernel)",
|
||||||
|
"language": "python",
|
||||||
|
"name": "python3"
|
||||||
|
},
|
||||||
|
"language_info": {
|
||||||
|
"codemirror_mode": {
|
||||||
|
"name": "ipython",
|
||||||
|
"version": 3
|
||||||
|
},
|
||||||
|
"file_extension": ".py",
|
||||||
|
"mimetype": "text/x-python",
|
||||||
|
"name": "python",
|
||||||
|
"nbconvert_exporter": "python",
|
||||||
|
"pygments_lexer": "ipython3",
|
||||||
|
"version": "3.9.7"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 5
|
||||||
|
}
|
@ -0,0 +1,53 @@
|
|||||||
|
{
|
||||||
|
"cells": [
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "d620c21c-89d5-4b37-888f-79212671d7db",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"# a raspberry orange tree"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "343265dc-49bd-4220-96aa-3ed2fbd1a54e",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"# https://www.reddit.com/r/aldi/comments/kqxzuc/the_raspberry_oranges_are_wonderful/"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "f519c19c-03f2-4332-be12-fd3beab81cb7",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"# pigment is shared between the raspberry species and the raspberry orange species"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"kernelspec": {
|
||||||
|
"display_name": "Python 3 (ipykernel)",
|
||||||
|
"language": "python",
|
||||||
|
"name": "python3"
|
||||||
|
},
|
||||||
|
"language_info": {
|
||||||
|
"codemirror_mode": {
|
||||||
|
"name": "ipython",
|
||||||
|
"version": 3
|
||||||
|
},
|
||||||
|
"file_extension": ".py",
|
||||||
|
"mimetype": "text/x-python",
|
||||||
|
"name": "python",
|
||||||
|
"nbconvert_exporter": "python",
|
||||||
|
"pygments_lexer": "ipython3",
|
||||||
|
"version": "3.9.7"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 5
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
{
|
||||||
|
"cells": [
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "574ccf52-a1c4-46b4-b7cc-7cea29cc6ff5",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"kernelspec": {
|
||||||
|
"display_name": "Python 3 (ipykernel)",
|
||||||
|
"language": "python",
|
||||||
|
"name": "python3"
|
||||||
|
},
|
||||||
|
"language_info": {
|
||||||
|
"codemirror_mode": {
|
||||||
|
"name": "ipython",
|
||||||
|
"version": 3
|
||||||
|
},
|
||||||
|
"file_extension": ".py",
|
||||||
|
"mimetype": "text/x-python",
|
||||||
|
"name": "python",
|
||||||
|
"nbconvert_exporter": "python",
|
||||||
|
"pygments_lexer": "ipython3",
|
||||||
|
"version": "3.9.7"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 5
|
||||||
|
}
|
@ -0,0 +1,194 @@
|
|||||||
|
{
|
||||||
|
"cells": [
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "f9f2a93f-62ee-411a-a8dd-2a6745444c02",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"# a sample tree, the starter program to begin all the trees with"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "c0e9adc4-5400-491d-a6bd-4ae93b4fbb38",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"\"\"\"Python3 program to demonstrate insert\n",
|
||||||
|
"operation in binary search tree \"\"\"\n",
|
||||||
|
"\n",
|
||||||
|
"# A Binary Tree Node\n",
|
||||||
|
"# Utility function to create a\n",
|
||||||
|
"# new tree node\n",
|
||||||
|
"class newNode:\n",
|
||||||
|
"\n",
|
||||||
|
" # Constructor to create a newNode\n",
|
||||||
|
" def __init__(self, data):\n",
|
||||||
|
" self.key= data\n",
|
||||||
|
" self.left = None\n",
|
||||||
|
" self.right = self.parent = None\n",
|
||||||
|
"\n",
|
||||||
|
"# A utility function to insert a new\n",
|
||||||
|
"# Node with given key in BST\n",
|
||||||
|
"def insert(root, key):\n",
|
||||||
|
"\n",
|
||||||
|
" # Create a new Node containing\n",
|
||||||
|
" # the new element\n",
|
||||||
|
" newnode = newNode(key)\n",
|
||||||
|
"\n",
|
||||||
|
" # Pointer to start traversing from root\n",
|
||||||
|
" # and traverses downward path to search\n",
|
||||||
|
" # where the new node to be inserted\n",
|
||||||
|
" x = root\n",
|
||||||
|
"\n",
|
||||||
|
" # Pointer y maintains the trailing\n",
|
||||||
|
" # pointer of x\n",
|
||||||
|
" y = None\n",
|
||||||
|
"\n",
|
||||||
|
" while (x != None):\n",
|
||||||
|
" y = x\n",
|
||||||
|
" if (key < x.key):\n",
|
||||||
|
" x = x.left\n",
|
||||||
|
" else:\n",
|
||||||
|
" x = x.right\n",
|
||||||
|
" \n",
|
||||||
|
" # If the root is None i.e the tree is\n",
|
||||||
|
" # empty. The new node is the root node\n",
|
||||||
|
" if (y == None):\n",
|
||||||
|
" y = newnode\n",
|
||||||
|
"\n",
|
||||||
|
" # If the new key is less then the leaf node key\n",
|
||||||
|
" # Assign the new node to be its left child\n",
|
||||||
|
" elif (key < y.key):\n",
|
||||||
|
" y.left = newnode\n",
|
||||||
|
"\n",
|
||||||
|
" # else assign the new node its\n",
|
||||||
|
" # right child\n",
|
||||||
|
" else:\n",
|
||||||
|
" y.right = newnode\n",
|
||||||
|
"\n",
|
||||||
|
" # Returns the pointer where the\n",
|
||||||
|
" # new node is inserted\n",
|
||||||
|
" return y\n",
|
||||||
|
"\n",
|
||||||
|
"# A utility function to do inorder\n",
|
||||||
|
"# traversal of BST\n",
|
||||||
|
"def Inorder(root) :\n",
|
||||||
|
"\n",
|
||||||
|
" if (root == None) :\n",
|
||||||
|
" return\n",
|
||||||
|
" else:\n",
|
||||||
|
" Inorder(root.left)\n",
|
||||||
|
" print( root.key, end = \" \" )\n",
|
||||||
|
" Inorder(root.right)\n",
|
||||||
|
"\n",
|
||||||
|
"#Driver Code\n",
|
||||||
|
"if __name__ == '__main__':\n",
|
||||||
|
"\n",
|
||||||
|
" root = None\n",
|
||||||
|
" root = insert(root, \"m\")\n",
|
||||||
|
" insert(root, \"n\")\n",
|
||||||
|
" insert(root, \"l\")\n",
|
||||||
|
" insert(root, \"p\")\n",
|
||||||
|
" insert(root, \"q\")\n",
|
||||||
|
" insert(root, \"a\")\n",
|
||||||
|
" insert(root, \"b\")\n",
|
||||||
|
"\n",
|
||||||
|
"\n",
|
||||||
|
" # Pr inorder traversal of the BST\n",
|
||||||
|
"\n",
|
||||||
|
"\n",
|
||||||
|
"# This code is contributed by\n",
|
||||||
|
"# SHUBHAMSINGH10"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 3,
|
||||||
|
"id": "921f4017-3f1f-4085-8da8-cc850fbd4c6e",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"\n",
|
||||||
|
" q\n",
|
||||||
|
"\n",
|
||||||
|
" p\n",
|
||||||
|
"\n",
|
||||||
|
" n\n",
|
||||||
|
"\n",
|
||||||
|
"m\n",
|
||||||
|
"\n",
|
||||||
|
" l\n",
|
||||||
|
"\n",
|
||||||
|
" b\n",
|
||||||
|
"\n",
|
||||||
|
" a\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"# print binary tree in 2D copied from sample program\n",
|
||||||
|
"COUNT = [10]\n",
|
||||||
|
"def print2DUtil(root, space) :\n",
|
||||||
|
"\n",
|
||||||
|
" # Base case\n",
|
||||||
|
" if (root == None) :\n",
|
||||||
|
" return\n",
|
||||||
|
"\n",
|
||||||
|
" # Increase distance between levels\n",
|
||||||
|
" space += COUNT[0]\n",
|
||||||
|
"\n",
|
||||||
|
" # Process right child first\n",
|
||||||
|
" print2DUtil(root.right, space)\n",
|
||||||
|
"\n",
|
||||||
|
" # Print current node after space\n",
|
||||||
|
" # count\n",
|
||||||
|
" print()\n",
|
||||||
|
" for i in range(COUNT[0], space):\n",
|
||||||
|
" print(end = \" \")\n",
|
||||||
|
" print(root.key)\n",
|
||||||
|
"\n",
|
||||||
|
" # Process left child\n",
|
||||||
|
" print2DUtil(root.left, space)\n",
|
||||||
|
"\n",
|
||||||
|
"# Wrapper over print2DUtil()\n",
|
||||||
|
"def print2D(root) :\n",
|
||||||
|
" \n",
|
||||||
|
" # space=[0]\n",
|
||||||
|
" # Pass initial space count as 0\n",
|
||||||
|
" print2DUtil(root, 0)\n",
|
||||||
|
"\n",
|
||||||
|
"# Driver Code\n",
|
||||||
|
"if __name__ == '__main__':\n",
|
||||||
|
"\n",
|
||||||
|
" \n",
|
||||||
|
" print2D(root)"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"kernelspec": {
|
||||||
|
"display_name": "Python 3 (ipykernel)",
|
||||||
|
"language": "python",
|
||||||
|
"name": "python3"
|
||||||
|
},
|
||||||
|
"language_info": {
|
||||||
|
"codemirror_mode": {
|
||||||
|
"name": "ipython",
|
||||||
|
"version": 3
|
||||||
|
},
|
||||||
|
"file_extension": ".py",
|
||||||
|
"mimetype": "text/x-python",
|
||||||
|
"name": "python",
|
||||||
|
"nbconvert_exporter": "python",
|
||||||
|
"pygments_lexer": "ipython3",
|
||||||
|
"version": "3.9.7"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 5
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
{
|
||||||
|
"cells": [
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "c17f30da-2c18-4e79-9000-a4e1757d076c",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"kernelspec": {
|
||||||
|
"display_name": "Python 3 (ipykernel)",
|
||||||
|
"language": "python",
|
||||||
|
"name": "python3"
|
||||||
|
},
|
||||||
|
"language_info": {
|
||||||
|
"codemirror_mode": {
|
||||||
|
"name": "ipython",
|
||||||
|
"version": 3
|
||||||
|
},
|
||||||
|
"file_extension": ".py",
|
||||||
|
"mimetype": "text/x-python",
|
||||||
|
"name": "python",
|
||||||
|
"nbconvert_exporter": "python",
|
||||||
|
"pygments_lexer": "ipython3",
|
||||||
|
"version": "3.9.7"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 5
|
||||||
|
}
|
@ -0,0 +1,49 @@
|
|||||||
|
{
|
||||||
|
"cells": [
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 1,
|
||||||
|
"id": "1cb5571e-af37-47eb-ba2d-5c10c87fbb9e",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"class tridentLeaf:\n",
|
||||||
|
" def __init__(self,something,somethingelse):\n",
|
||||||
|
" self.leftProng = None\n",
|
||||||
|
" self.middleProng = None\n",
|
||||||
|
" self.rightProng = None\n",
|
||||||
|
" self.something = something\n",
|
||||||
|
" self.somethingelse = somethingelse"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "6c797c5b-e7e0-432f-9a85-27e7c6e1bdc9",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"kernelspec": {
|
||||||
|
"display_name": "Python 3 (ipykernel)",
|
||||||
|
"language": "python",
|
||||||
|
"name": "python3"
|
||||||
|
},
|
||||||
|
"language_info": {
|
||||||
|
"codemirror_mode": {
|
||||||
|
"name": "ipython",
|
||||||
|
"version": 3
|
||||||
|
},
|
||||||
|
"file_extension": ".py",
|
||||||
|
"mimetype": "text/x-python",
|
||||||
|
"name": "python",
|
||||||
|
"nbconvert_exporter": "python",
|
||||||
|
"pygments_lexer": "ipython3",
|
||||||
|
"version": "3.9.7"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 5
|
||||||
|
}
|
@ -0,0 +1,46 @@
|
|||||||
|
{
|
||||||
|
"cells": [
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "baf7d8e8-1cc2-4f18-b5a7-ce5bb7c45bef",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"# a cutting tree"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "b6057018-bdeb-429a-8e66-130419251ef9",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"# during an evening walk after the marshall fire, i saw a local\n",
|
||||||
|
"# tree trimming company handling trees that were either entirely \n",
|
||||||
|
"# fallen off or were dangling. the trees needed to be removed as\n",
|
||||||
|
"# they may be of hazard for the pedestrians and the road. "
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"kernelspec": {
|
||||||
|
"display_name": "Python 3 (ipykernel)",
|
||||||
|
"language": "python",
|
||||||
|
"name": "python3"
|
||||||
|
},
|
||||||
|
"language_info": {
|
||||||
|
"codemirror_mode": {
|
||||||
|
"name": "ipython",
|
||||||
|
"version": 3
|
||||||
|
},
|
||||||
|
"file_extension": ".py",
|
||||||
|
"mimetype": "text/x-python",
|
||||||
|
"name": "python",
|
||||||
|
"nbconvert_exporter": "python",
|
||||||
|
"pygments_lexer": "ipython3",
|
||||||
|
"version": "3.9.7"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 5
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
{
|
||||||
|
"cells": [
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "cd29e163-6a53-4f3a-a6c7-d6489f85f405",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"kernelspec": {
|
||||||
|
"display_name": "Python 3 (ipykernel)",
|
||||||
|
"language": "python",
|
||||||
|
"name": "python3"
|
||||||
|
},
|
||||||
|
"language_info": {
|
||||||
|
"codemirror_mode": {
|
||||||
|
"name": "ipython",
|
||||||
|
"version": 3
|
||||||
|
},
|
||||||
|
"file_extension": ".py",
|
||||||
|
"mimetype": "text/x-python",
|
||||||
|
"name": "python",
|
||||||
|
"nbconvert_exporter": "python",
|
||||||
|
"pygments_lexer": "ipython3",
|
||||||
|
"version": "3.9.7"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 5
|
||||||
|
}
|
@ -0,0 +1,40 @@
|
|||||||
|
# A Letter Tree With Hanging Fruits
|
||||||
|
|
||||||
|
## What
|
||||||
|
"A Letter Tree With Hanging Fruits" is a symbolic tree that grows 26 different fruits, with each name starting with a letter from the English alphabet. The computer program uses the tree structure, an abstract data structure used to store, retrieve and represent hierarchical information. The information, in this case, a list containing the words of the fruits, is processed hierarchically by recursion, an algorithmic procedure that constantly calls upon itself until an exit condition is met.
|
||||||
|
|
||||||
|
## How
|
||||||
|
There are two recursive procedures applied in the program, one to build the tree, and the other to print the tree. Between line 45 and 67, the insertLeaf function recursively traverse the tree, looking for a suitable place to insert the word of the fruit as predefined by a hierarchical rule. The hierarchical rule used in the program simply compares the order of the word's first letter. Words starting with "bigger" letters will be placed on the right side, and vice versa. Between line 15 and 35, the print2DUtil_flat function visually renders the tree's levelled hierarchies. The function starts in the tree's furthest right. For words placed in "lower" levels, more empty spaces are printed, and vice versa.
|
||||||
|
|
||||||
|
## Why
|
||||||
|
The program is intended to be a simple yet playful reflection on the convergence of mathematics, language, and symbol. While the program's association with these subjects may immediately sound daunting, as the audience pays inquisitive attention to how the program's outputs are being rendered interactively in the console, they are witnessing a tangible interplay of the subjects.
|
||||||
|
|
||||||
|
Originally, the program was written as a response to a piece of archival information found on the subject of Chinese text processing. Due to the incompatibilities resulted from organizational differences between Chinese as an ideographic writing system and alphanumeric writing systems, such as English, advanced Chinese text processing technologies were near scarce in the early history of computing. Computationally, it was expensive and hence incompatible to accommodate a corpus of Chinese glyphs in the systems of hardware and software first intended to process alphanumeric writing systems. Here, the concept of incompatibility derives from singularly determined frameworks that are efficient and monolingual. Outside the singularly determined frameworks, there is a rich ecology of artifacts, approaches, and interpretations on Chinese text processing that each embody uniqueness and idiosyncrasy.
|
||||||
|
|
||||||
|
Take the archival information as an example. In the early 1990s, the Chinese writer and programmer Wang Xiaobo was crafting a Chinese text editor. Wang used a binary tree structure to implement a feature to store customized word combinations.
|
||||||
|
|
||||||
|
Hierarchy
|
||||||
|
Dynamic programming
|
||||||
|
Self generation of recursion
|
||||||
|
Self modification
|
||||||
|
permutation
|
||||||
|
Recursion in computational linguistics
|
||||||
|
dabai dabaicai dabaiyutianxia
|
||||||
|
|
||||||
|
|
||||||
|
The attention to science and mathematics permeates his writing.
|
||||||
|
|
||||||
|
hierarchical rule
|
||||||
|
camel case and snake case
|
||||||
|
Tree of life in (esoteric) mystery spiritualism trees
|
||||||
|
|
||||||
|
typographical qualities
|
||||||
|
empty spaces
|
||||||
|
vacancies
|
||||||
|
|
||||||
|
## Ring
|
||||||
|
"I Like Mathematics And Tight Pants"
|
||||||
|
"https://sfpc.study/sessions/summer-22/learning-to-love-math"
|
||||||
|
Qianxun Chen's seedlings
|
||||||
|
Metamagical thema "structure and strangeness"
|
||||||
|
<!-- will a handwritten dynamic gif like taeyoon choi's be helpful for the thing?-- >
|
@ -0,0 +1,33 @@
|
|||||||
|
{
|
||||||
|
"cells": [
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "65ca64ef-5513-45b8-8e06-7538efd2b6c1",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"kernelspec": {
|
||||||
|
"display_name": "Python 3 (ipykernel)",
|
||||||
|
"language": "python",
|
||||||
|
"name": "python3"
|
||||||
|
},
|
||||||
|
"language_info": {
|
||||||
|
"codemirror_mode": {
|
||||||
|
"name": "ipython",
|
||||||
|
"version": 3
|
||||||
|
},
|
||||||
|
"file_extension": ".py",
|
||||||
|
"mimetype": "text/x-python",
|
||||||
|
"name": "python",
|
||||||
|
"nbconvert_exporter": "python",
|
||||||
|
"pygments_lexer": "ipython3",
|
||||||
|
"version": "3.9.7"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 5
|
||||||
|
}
|
@ -0,0 +1,43 @@
|
|||||||
|
{
|
||||||
|
"cells": [
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "2691ed6e-f79f-4b86-abee-e8453d20c528",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"# an html tree"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "d8ba1dd7-1f42-4eb0-84a2-0bee2fc96f49",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"#"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"kernelspec": {
|
||||||
|
"display_name": "Python 3 (ipykernel)",
|
||||||
|
"language": "python",
|
||||||
|
"name": "python3"
|
||||||
|
},
|
||||||
|
"language_info": {
|
||||||
|
"codemirror_mode": {
|
||||||
|
"name": "ipython",
|
||||||
|
"version": 3
|
||||||
|
},
|
||||||
|
"file_extension": ".py",
|
||||||
|
"mimetype": "text/x-python",
|
||||||
|
"name": "python",
|
||||||
|
"nbconvert_exporter": "python",
|
||||||
|
"pygments_lexer": "ipython3",
|
||||||
|
"version": "3.9.7"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 5
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
{
|
||||||
|
"cells": [
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "8ffb184c-7941-44a6-84c4-422ba9deac43",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"kernelspec": {
|
||||||
|
"display_name": "Python 3 (ipykernel)",
|
||||||
|
"language": "python",
|
||||||
|
"name": "python3"
|
||||||
|
},
|
||||||
|
"language_info": {
|
||||||
|
"codemirror_mode": {
|
||||||
|
"name": "ipython",
|
||||||
|
"version": 3
|
||||||
|
},
|
||||||
|
"file_extension": ".py",
|
||||||
|
"mimetype": "text/x-python",
|
||||||
|
"name": "python",
|
||||||
|
"nbconvert_exporter": "python",
|
||||||
|
"pygments_lexer": "ipython3",
|
||||||
|
"version": "3.9.7"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 5
|
||||||
|
}
|
After Width: | Height: | Size: 31 KiB |
After Width: | Height: | Size: 220 KiB |
After Width: | Height: | Size: 55 KiB |
After Width: | Height: | Size: 445 KiB |
After Width: | Height: | Size: 430 KiB |
After Width: | Height: | Size: 434 KiB |
After Width: | Height: | Size: 509 KiB |
After Width: | Height: | Size: 2.6 MiB |
After Width: | Height: | Size: 39 KiB |
After Width: | Height: | Size: 8.9 KiB |
After Width: | Height: | Size: 52 KiB |
After Width: | Height: | Size: 93 KiB |
After Width: | Height: | Size: 418 KiB |
After Width: | Height: | Size: 320 KiB |
After Width: | Height: | Size: 93 KiB |
After Width: | Height: | Size: 196 KiB |
After Width: | Height: | Size: 186 KiB |
After Width: | Height: | Size: 194 KiB |
After Width: | Height: | Size: 133 KiB |
After Width: | Height: | Size: 30 KiB |
After Width: | Height: | Size: 94 KiB |
After Width: | Height: | Size: 134 KiB |
After Width: | Height: | Size: 100 KiB |
After Width: | Height: | Size: 17 KiB |
After Width: | Height: | Size: 214 KiB |
After Width: | Height: | Size: 204 KiB |
After Width: | Height: | Size: 57 KiB |
After Width: | Height: | Size: 15 KiB |
After Width: | Height: | Size: 136 KiB |
After Width: | Height: | Size: 87 KiB |
After Width: | Height: | Size: 70 KiB |
After Width: | Height: | Size: 84 KiB |
After Width: | Height: | Size: 185 KiB |
After Width: | Height: | Size: 83 KiB |
After Width: | Height: | Size: 96 KiB |
After Width: | Height: | Size: 280 KiB |
After Width: | Height: | Size: 244 KiB |
After Width: | Height: | Size: 388 KiB |
After Width: | Height: | Size: 205 KiB |
After Width: | Height: | Size: 107 KiB |
After Width: | Height: | Size: 39 KiB |
After Width: | Height: | Size: 8.9 KiB |
After Width: | Height: | Size: 52 KiB |
After Width: | Height: | Size: 93 KiB |
After Width: | Height: | Size: 418 KiB |