





"""simple docstring"""






from collections.abc import Iterable
from typing import Any




class 			__lowercase     :







					'''simple docstring'''




					def __init__(  self		,     _UpperCAmelCase = None       ):
									__a	:  Any         =					value
									__a	:  Node | None         =					None  # Added in order to delete a node easier
									__a	:  Node | None         =					None
									__a	:  Node | None         =					None







					def __repr__(  self       ):
									from pprint import pformat

									if self.left is None and self.right is None:
													return str(self.value       )
									return pformat({f"""{self.value}""": (self.left, self.right)}		,     indent=1       )






class 			__lowercase     :







					'''simple docstring'''




					def __init__(  self		,     _UpperCAmelCase = None       ):
									__a	:  int         =					root







					def __str__(  self       ):
									return str(self.root       )







					def 	_lowerCamelCase						(  self		,     _UpperCAmelCase		,     _UpperCAmelCase       ):
									if new_children is not None:  # reset its kids
													__a	:  Dict         =					node.parent
									if node.parent is not None:  # reset its parent
													if self.is_right(_UpperCAmelCase       ):  # If it is the right children
																	__a	:  Any         =					new_children
													else:
																	__a	:  Dict         =					new_children
									else:
													__a	:  Any         =					new_children







					def 	_lowerCamelCase						(  self		,     _UpperCAmelCase       ):
									if node.parent and node.parent.right:
													return node == node.parent.right
									return False







					def 	_lowerCamelCase						(  self       ):
									return self.root is None







					def 	_lowerCamelCase						(  self		,     _UpperCAmelCase       ):
									__a	:  Tuple         =					Node(_UpperCAmelCase       )  # create a new Node
									if self.empty():  # if Tree is empty
													__a	:  Tuple         =					new_node  # set its root
									else:  # Tree is not empty
													__a	:  Optional[int]         =					self.root  # from root
													if parent_node is None:
																	return
													while True:  # While we don't get to a leaf
																	if value < parent_node.value:  # We go left
																					if parent_node.left is None:
																									__a	:  int         =					new_node  # We insert the new node in a leaf
																									break
																					else:
																									__a	:  Union[str, Any]         =					parent_node.left
																	else:
																					if parent_node.right is None:
																									__a	:  Tuple         =					new_node
																									break
																					else:
																									__a	:  List[Any]         =					parent_node.right
													__a	:  Any         =					parent_node







					def 	_lowerCamelCase						(  self		,     *_UpperCAmelCase       ):
									for value in values:
													self.__insert(_UpperCAmelCase       )







					def 	_lowerCamelCase						(  self		,     _UpperCAmelCase       ):
									if self.empty():
													raise IndexError('''Warning: Tree is empty! please use another.'''       )
									else:
													__a	:  List[str]         =					self.root
													# use lazy evaluation here to avoid NoneType Attribute error
													while node is not None and node.value is not value:
																	__a	:  List[Any]         =					node.left if value < node.value else node.right
													return node







					def 	_lowerCamelCase						(  self		,     _UpperCAmelCase = None       ):
									if node is None:
													if self.root is None:
																	return None
													__a	:  Union[str, Any]         =					self.root

									if not self.empty():
													while node.right is not None:
																	__a	:  Optional[int]         =					node.right
									return node







					def 	_lowerCamelCase						(  self		,     _UpperCAmelCase = None       ):
									if node is None:
													__a	:  str         =					self.root
									if self.root is None:
													return None
									if not self.empty():
													__a	:  Any         =					self.root
													while node.left is not None:
																	__a	:  Optional[Any]         =					node.left
									return node







					def 	_lowerCamelCase						(  self		,     _UpperCAmelCase       ):
									__a	:  List[Any]         =					self.search(_UpperCAmelCase       )  # Look for the node with that label
									if node is not None:
													if node.left is None and node.right is None:  # If it has no children
																	self.__reassign_nodes(_UpperCAmelCase		,     _UpperCAmelCase       )
													elif node.left is None:  # Has only right children
																	self.__reassign_nodes(_UpperCAmelCase		,     node.right       )
													elif node.right is None:  # Has only left children
																	self.__reassign_nodes(_UpperCAmelCase		,     node.left       )
													else:
																	__a	:  List[str]         =					self.get_max(
																	    node.left       )  # Gets the max value of the left branch
																	self.remove(tmp_node.value       )  # type: ignore
																	__a	:  List[str]         =					(
																	    tmp_node.value  # type: ignore
																	)  # Assigns the value to the node to delete and keep tree structure







					def 	_lowerCamelCase						(  self		,     _UpperCAmelCase       ):
									if node is not None:
													yield node  # Preorder Traversal
													yield from self.preorder_traverse(node.left       )
													yield from self.preorder_traverse(node.right       )







					def 	_lowerCamelCase						(  self		,     _UpperCAmelCase=None       ):
									if traversal_function is None:
													return self.preorder_traverse(self.root       )
									else:
													return traversal_function(self.root       )







					def 	_lowerCamelCase						(  self		,     _UpperCAmelCase		,     _UpperCAmelCase       ):
									if node:
													self.inorder(_UpperCAmelCase		,     node.left       )
													arr.append(node.value       )
													self.inorder(_UpperCAmelCase		,     node.right       )







					def 	_lowerCamelCase						(  self		,     _UpperCAmelCase		,     _UpperCAmelCase       ):
									__a	:  list[int]         =					[]
									self.inorder(_UpperCAmelCase		,     _UpperCAmelCase       )  # append all values to list using inorder traversal
									return arr[k - 1]






def       __A (     a_  :Node | None)						->						list[Node]:
				__a	:  Tuple         =					[]
				if curr_node is not None:
								__a	:  str         =					postorder(curr_node.left) + postorder(curr_node.right) + [curr_node]
				return node_list

def       __A (     )						->						None:
				__a	:  List[str]         =					(8, 3, 6, 1, 10, 14, 13, 4, 7)
				__a	:  Any         =					BinarySearchTree()
				for i in testlist:
								t.insert(a_)

				# Prints all the elements of the list in order traversal
				print(a_)

				if t.search(6) is not None:
								print('''The value 6 exists''')
				else:
								print('''The value 6 doesn\'t exist''')

				if t.search(-1) is not None:
								print('''The value -1 exists''')
				else:
								print('''The value -1 doesn\'t exist''')

				if not t.empty():
								print('''Max Value: '''				,    t.get_max().value)  # type: ignore
								print('''Min Value: '''				,    t.get_min().value)  # type: ignore

				for i in testlist:
								t.remove(a_)
								print(a_)


if __name__ == "__main__":
		import doctest

		doctest.testmod(verbose=True)






"""simple docstring"""






def       __A (     a_  :float)						->						float:

				if edge <= 0 or not isinstance(a_				,    a_):
								raise ValueError('''Length must be a positive.''')
				return 3 * ((25 + 10 * (5 ** (1 / 2))) ** (1 / 2)) * (edge**2)

def       __A (     a_  :float)						->						float:

				if edge <= 0 or not isinstance(a_				,    a_):
								raise ValueError('''Length must be a positive.''')
				return ((15 + (7 * (5 ** (1 / 2)))) / 4) * (edge**3)


if __name__ == "__main__":
		import doctest

		doctest.testmod()