Skip to content

Commit a308e38

Browse files
committed
Added Binary Search Tree implementation
1 parent b7c7372 commit a308e38

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

pygorithm/data_structures/tree.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,11 @@ def postorder(self, root):
226226
self._postorder.append(root.get_data()) # get the data of current node
227227
return self._postorder
228228

229+
# easily retrieve the source code of the BSTNode class
230+
def get_code(self):
231+
import inspect
232+
return inspect.getsource(BSTNode)
233+
229234
class BinarySearchTree(object):
230235
def __init__(self):
231236
self.root = None
@@ -260,3 +265,8 @@ def postorder(self):
260265
print()
261266
if self.root is not None:
262267
return self.root.postorder(self.root)
268+
269+
# easily retrieve the source code of the BinarySearchTree class
270+
def get_code(self):
271+
import inspect
272+
return inspect.getsource(BinarySearchTree)

0 commit comments

Comments
 (0)