mirror of
https://github.com/donnemartin/interactive-coding-challenges
synced 2026-01-09 19:08:02 +00:00
Polish bst challenge and solution (#75)
Update constraints, algorithm discussion, and code.
This commit is contained in:
@@ -33,6 +33,8 @@
|
||||
"source": [
|
||||
"## Constraints\n",
|
||||
"\n",
|
||||
"* Can we insert None values?\n",
|
||||
" * No\n",
|
||||
"* Can we assume we are working with valid integers?\n",
|
||||
" * Yes\n",
|
||||
"* Can we assume all left descendents <= n < all right descendents?\n",
|
||||
@@ -40,7 +42,9 @@
|
||||
"* For simplicity, can we use just a Node class without a wrapper Tree class?\n",
|
||||
" * Yes\n",
|
||||
"* Do we have to keep track of the parent nodes?\n",
|
||||
" * This is optional"
|
||||
" * This is optional\n",
|
||||
"* Can we assume this fits in memory?\n",
|
||||
" * Yes"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -53,12 +57,14 @@
|
||||
"\n",
|
||||
"Insert will be tested through the following traversal:\n",
|
||||
"\n",
|
||||
"### In-Order Traversal (Provided)\n",
|
||||
"### In-Order Traversal\n",
|
||||
"\n",
|
||||
"* 5, 2, 8, 1, 3 -> 1, 2, 3, 5, 8\n",
|
||||
"* 1, 2, 3, 4, 5 -> 1, 2, 3, 4, 5\n",
|
||||
"\n",
|
||||
"If the `root` input is `None`, return a tree with the only element being the new root node."
|
||||
"If the `root` input is `None`, return a tree with the only element being the new root node.\n",
|
||||
"\n",
|
||||
"You do not have to code the in-order traversal, it is part of the unit test."
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -206,7 +212,7 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.4.3"
|
||||
"version": "3.5.0"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
|
||||
Reference in New Issue
Block a user