[mypy] Fix type annotations in `data_structures/binary_tree` (#5518) · zinating/algorithms-python@629848e · GitHub
Skip to content

Commit 629848e

Browse files
shermanhuigithub-actions
andauthored
[mypy] Fix type annotations in data_structures/binary_tree (TheAlgorithms#5518)
* fix: fix mypy errors Update binary_search_tree `arr` argument to be typed as a list within `find_kth_smallest` function Update return type of `merge_two_binary_trees` as both inputs can be None which means that a None type value can be returned from this function * updating DIRECTORY.md Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
1 parent d82cf52 commit 629848e

3 files changed

Lines changed: 5 additions & 2 deletions

File tree

DIRECTORY.md

Lines changed: 1 addition & 0 deletions

data_structures/binary_tree/binary_search_tree.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ def inorder(self, arr: list, node: Node):
151151

152152
def find_kth_smallest(self, k: int, node: Node) -> int:
153153
"""Return the kth smallest element in a binary search tree"""
154-
arr = []
154+
arr: list = []
155155
self.inorder(arr, node) # append all values to list using inorder traversal
156156
return arr[k - 1]
157157

data_structures/binary_tree/merge_two_binary_trees.py

Lines changed: 3 additions & 1 deletion

0 commit comments

Comments
 (0)