


"""simple docstring"""
class        __A       :





							'''simple docstring'''

							def __init__(			self							: Optional[Any]						,    UpperCAmelCase_							: int    )   ->Tuple:



														"""simple docstring"""



														snake_case_          =						val
														snake_case_          =						None
														snake_case_          =						None



							def 						lowerCAmelCase    (			self							: List[Any]						,    UpperCAmelCase_							: List[Any]    )   ->Dict:



														"""simple docstring"""



														if self.val:
																					if val < self.val:
																												if self.left is None:
																																			snake_case_          =						Node(UpperCAmelCase_    )
																												else:
																																			self.left.insert(UpperCAmelCase_    )
																					elif val > self.val:
																												if self.right is None:
																																			snake_case_          =						Node(UpperCAmelCase_    )
																												else:
																																			self.right.insert(UpperCAmelCase_    )
														else:
																					snake_case_          =						val







def   _a			( _SCREAMING_SNAKE_CASE			,	_SCREAMING_SNAKE_CASE			)      ->			Dict:
							# Recursive traversal
							if root:
														inorder(root.left			,	_SCREAMING_SNAKE_CASE			)
														res.append(root.val			)
														inorder(root.right			,	_SCREAMING_SNAKE_CASE			)







def   _a			( _SCREAMING_SNAKE_CASE			)      ->			Optional[int]:
							# Build BST
							if len(_SCREAMING_SNAKE_CASE			) == 0:
														return arr
							snake_case_          =						Node(arr[0]			)
							for i in range(1			,	len(_SCREAMING_SNAKE_CASE			)			):
														root.insert(arr[i]			)
							# Traverse BST in order.
							snake_case_          =						[]
							inorder(_SCREAMING_SNAKE_CASE			,	_SCREAMING_SNAKE_CASE			)
							return res


if __name__ == "__main__":
				print(tree_sort([10, 1, 3, 2, 9, 14, 13]))







"""simple docstring"""
import math





class        __A       :





							'''simple docstring'''

							def __init__(			self							: List[str]						,    UpperCAmelCase_							: Tuple=0    )   ->Optional[int]:  # a graph with Node 0,1,...,N-1



														"""simple docstring"""



														snake_case_          =						n
														snake_case_          =						[
														    [math.inf for j in range(0						,    UpperCAmelCase_    )] for i in range(0						,    UpperCAmelCase_    )
														]  # adjacency matrix for weight
														snake_case_          =						[
														    [math.inf for j in range(0						,    UpperCAmelCase_    )] for i in range(0						,    UpperCAmelCase_    )
														]  # dp[i][j] stores minimum distance from i to j



							def 						lowerCAmelCase    (			self							: List[str]						,    UpperCAmelCase_							: Any						,    UpperCAmelCase_							: List[str]						,    UpperCAmelCase_							: Optional[Any]    )   ->Optional[int]:



														"""simple docstring"""



														snake_case_          =						w



							def 						lowerCAmelCase    (			self							: Optional[int]    )   ->Any:



														"""simple docstring"""



														for k in range(0						,    self.n    ):
																					for i in range(0						,    self.n    ):
																												for j in range(0						,    self.n    ):
																																			snake_case_          =						min(self.dp[i][j]						,    self.dp[i][k] + self.dp[k][j]    )



							def 						lowerCAmelCase    (			self							: Optional[int]						,    UpperCAmelCase_							: Dict						,    UpperCAmelCase_							: Optional[Any]    )   ->Union[str, Any]:



														"""simple docstring"""



														return self.dp[u][v]


if __name__ == "__main__":
				__SCREAMING_SNAKE_CASE							:      Optional[int]						=      Graph(5)
				graph.add_edge(0, 2, 9)
				graph.add_edge(0, 4, 10)
				graph.add_edge(1, 3, 5)
				graph.add_edge(2, 3, 7)
				graph.add_edge(3, 0, 10)
				graph.add_edge(3, 1, 2)
				graph.add_edge(3, 2, 1)
				graph.add_edge(3, 4, 6)
				graph.add_edge(4, 1, 3)
				graph.add_edge(4, 2, 4)
				graph.add_edge(4, 3, 9)
				graph.floyd_warshall()
				graph.show_min(1, 4)
				graph.show_min(0, 3)



