You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Class10.md
-3
Original file line number
Diff line number
Diff line change
@@ -15,9 +15,6 @@
15
15
- Play with VisuAlgo's [interactive binary search tree visualization][visualgo bst]
16
16
17
17
### Challenges
18
-
- Implement recursive tree search methods on the `BinarySearchTree` class using [binary tree starter code]:
19
-
-`_find_node_recursive(item)` - return the node containing `item` in the tree, or `None` if not found (*hint: implement this first*)
20
-
-`_find_parent_node_recursive(item)` - return the parent of the node containing `item` (or the parent of where `item` would be if inserted) in the tree, or `None` if the tree is empty or has only a root node
21
18
- Implement tree traversal methods on the `BinarySearchTree` class using [binary tree starter code]:
22
19
-`_traverse_in_order_recursive` - traverse the tree with recursive in-order traversal (DFS)
23
20
-`_traverse_pre_order_recursive` - traverse the tree with recursive pre-order traversal (DFS)
Copy file name to clipboardExpand all lines: Class8.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@
9
9
- Read Vaidehi Joshi's [article on sets and their use in databases][BaseCS sets] with beautiful drawings and excellent examples
10
10
11
11
### Challenges
12
-
- Implement `Set` class (backed by hash table) with the following [set operations] as instance methods and properties:
12
+
- Implement `Set` class (abstract data type backed by data structure of your choice) with the following [set operations] as instance methods and properties:
13
13
-`__init__(elements=None)` - initialize a new empty set structure, and add each element if a sequence is given
14
14
-`size` - property that tracks the number of elements in constant time
15
15
-`contains(element)` - return a boolean indicating whether `element` is in this set
Copy file name to clipboardExpand all lines: Class9.md
+8-3
Original file line number
Diff line number
Diff line change
@@ -21,16 +21,19 @@
21
21
-`is_leaf` - check if the node is a leaf (an external node that has no children)
22
22
-`is_branch` - check if the node is a branch (an internal node that has at least one child)
23
23
-`height` - return the node's height (the number of edges on the longest downward path from the node to a descendant leaf node)
24
-
- Implement `BinarySearchTree` class using `BinaryTreeNode` objects with the following properties and instance methods using [binary tree starter code]:
24
+
- Implement `BinarySearchTree` class (using `BinaryTreeNode` objects) with the following properties and instance methods using [binary tree starter code]:
25
25
-`root` - the tree's root node, or `None` (if the tree is empty)
26
26
-`size` - property that tracks the number of nodes in constant time
27
27
-`is_empty` - check if the tree is empty (has no nodes)
28
28
-`height` - return the tree's height (the number of edges on the longest downward path from the tree's root node to a descendant leaf node)
29
29
-`contains(item)` - return a boolean indicating whether `item` is present in the tree
30
30
-`search(item)` - return an item in the tree matching the given `item`, or `None` if not found
31
31
-`insert(item)` - insert the given `item` in order into the tree
32
-
-`_find_node(item)` - return the node containing `item` in the tree, or `None` if not found (*hint: implement this first*)
33
-
-`_find_parent_node(item)` - return the parent of the node containing `item` (or the parent of where `item` would be if inserted) in the tree, or `None` if the tree is empty or has only a root node
32
+
- To simplify the `contains`, `search`, and `insert` methods with code reuse, implement iterative and recursive tree search helper methods:
33
+
-`_find_node_iterative(item)` - return the node containing `item` in the tree, or `None` if not found
34
+
-`_find_node_recursive(item)` - return the node containing `item` in the tree, or `None` if not found
35
+
-`_find_parent_node_iterative(item)` - return the parent of the node containing `item` (or the parent of where `item` would be if inserted) in the tree, or `None` if the tree is empty or has only a root node
36
+
-`_find_parent_node_recursive(item)` - return the parent of the node containing `item` (or the parent of where `item` would be if inserted) in the tree, or `None` if the tree is empty or has only a root node
34
37
- Run `python binarytree.py` to test `BinarySearchTree` class instance methods on a small example
35
38
- Run `pytest binarytree_test.py` to run the [binary tree unit tests] and fix any failures
36
39
- Write additional unit tests for the `BinaryTreeNode` and `BinarySearchTree` classes
@@ -41,6 +44,8 @@
41
44
### Stretch Challenges
42
45
- Implement this additional `BinarySearchTree` class instance method:
43
46
-`delete(item)` - remove `item` from the tree, if present, or else raise `ValueError` (*hint: break this down into cases based on how many children the node containing `item` has and implement helper methods for subtasks of the more complex cases*)
47
+
- Write additional unit tests for the `BinarySearchTree` class
48
+
- Include several test cases for the `delete` instance method covering each case handled by the algorithm
44
49
- Implement binary search tree with singly linked list nodes (having only one link to another node) instead of binary tree nodes (having two links to other nodes)
0 commit comments