Skip to content

Commit bea9809

Browse files
committed
kth_smallest_value_in_a_binary_search_tree
1 parent 366bd1e commit bea9809

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

data_structures/binary_tree/kth_smallest_value_in_a_binary_search_tree.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
21
from typing import Optional
32

4-
3+
54
class Node:
65
"""
76
A Node has data variable and pointers to Nodes to its left and right.
@@ -12,6 +11,7 @@ def __init__(self, data: int) -> None:
1211
self.left: Optional[Node] = None
1312
self.right: Optional[Node] = None
1413

14+
1515
def kthSmallest(root: Node, k: int) -> int:
1616
"""
1717
In a BST, the Inorder Traversal returns ascending order of the data when traversed.
@@ -31,6 +31,7 @@ def kthSmallest(root: Node, k: int) -> int:
3131
root = root.right
3232
return temp[k - 1]
3333

34+
3435
if __name__ == "__main__":
3536
tree = Node(5)
3637
tree.left = Node(3)

0 commit comments

Comments
 (0)