
"""simple docstring"""

from __future__ import annotations

from collections import deque
from collections.abc import Sequence
from dataclasses import dataclass
from typing import Any






@dataclass
class 	_lowercase       :
	lowercase_				=     42
	lowercase_				=     None
	lowercase_				=     None


def 		UpperCAmelCase (		):





		'''simple docstring'''


		lowerCamelCase					:      Union[str, Any]          =   Node(1      )
		lowerCamelCase					:      int          =   Node(2      )
		lowerCamelCase					:      Any          =   Node(3      )
		lowerCamelCase					:      Tuple          =   Node(4      )
		lowerCamelCase					:      Dict          =   Node(5      )
		return tree
def 		UpperCAmelCase (		a_      ):





		'''simple docstring'''


		return [root.data, *preorder(root.left      ), *preorder(root.right      )] if root else []
def 		UpperCAmelCase (		a_      ):





		'''simple docstring'''


		return postorder(root.left      ) + postorder(root.right      ) + [root.data] if root else []
def 		UpperCAmelCase (		a_      ):





		'''simple docstring'''


		return [*inorder(root.left      ), root.data, *inorder(root.right      )] if root else []
def 		UpperCAmelCase (		a_      ):





		'''simple docstring'''


		return (max(height(root.left      ),						height(root.right      )      ) + 1) if root else 0
def 		UpperCAmelCase (		a_      ):





		'''simple docstring'''


		lowerCamelCase					:      Union[str, Any]          =   []

		if root is None:
				return output

		lowerCamelCase					:      str          =   deque([root]      )

		while process_queue:
				lowerCamelCase					:      int          =   process_queue.popleft()
				output.append(node.data      )

				if node.left:
						process_queue.append(node.left      )
				if node.right:
						process_queue.append(node.right      )
		return output
def 		UpperCAmelCase (		a_,						a_      ):





		'''simple docstring'''


		lowerCamelCase					:      Optional[int]          =   []

		def populate_output(a_,						a_      ) -> None:
				if not root:
						return
				if level == 1:
						output.append(root.data      )
				elif level > 1:
						populate_output(root.left,						level - 1      )
						populate_output(root.right,						level - 1      )

		populate_output(__snake_case,						__snake_case      )
		return output
def 		UpperCAmelCase (		a_,						a_      ):





		'''simple docstring'''


		lowerCamelCase					:      Dict          =   []

		def populate_output(a_,						a_      ) -> None:
				if root is None:
						return
				if level == 1:
						output.append(root.data      )
				elif level > 1:
						populate_output(root.right,						level - 1      )
						populate_output(root.left,						level - 1      )

		populate_output(__snake_case,						__snake_case      )
		return output
def 		UpperCAmelCase (		a_      ):





		'''simple docstring'''


		if root is None:
				return []

		lowerCamelCase					:      List[str]          =   []

		lowerCamelCase					:      Any          =   0
		lowerCamelCase					:      Dict          =   height(__snake_case      )

		for h in range(1,						height_tree + 1      ):
				if not flag:
						output.append(get_nodes_from_left_to_right(__snake_case,						__snake_case      )      )
						lowerCamelCase					:      List[Any]          =   1
				else:
						output.append(get_nodes_from_right_to_left(__snake_case,						__snake_case      )      )
						lowerCamelCase					:      List[Any]          =   0

		return output
def 		UpperCAmelCase (		):  # Main function for testing.





		'''simple docstring'''


		lowerCamelCase					:      Dict          =   make_tree()
		print(F"""In-order Traversal: {inorder(__snake_case      )}"""      )
		print(F"""Pre-order Traversal: {preorder(__snake_case      )}"""      )
		print(F"""Post-order Traversal: {postorder(__snake_case      )}""",						'\n'      )

		print(F"""Height of Tree: {height(__snake_case      )}""",						'\n'      )

		print('Complete Level Order Traversal: '      )
		print(level_order(__snake_case      ),						'\n'      )

		print('Level-wise order Traversal: '      )

		for level in range(1,						height(__snake_case      ) + 1      ):
				print(F"""Level {level}:""",						get_nodes_from_left_to_right(__snake_case,						level=__snake_case      )      )

		print('\nZigZag order Traversal: '      )
		print(zigzag(__snake_case      )      )


if __name__ == "__main__":
					import doctest

					doctest.testmod()
					main()








"""simple docstring"""

def 		UpperCAmelCase (		a_ = 1000      ):





		'''simple docstring'''


		lowerCamelCase					:      Dict          =   2**power
		lowerCamelCase					:      List[str]          =   str(a_      )
		lowerCamelCase					:      Dict          =   list(a_      )
		lowerCamelCase					:      Optional[Any]          =   0

		for i in list_num:
				sum_of_num += int(a_      )

		return sum_of_num


if __name__ == "__main__":
					_A						=			int(input('Enter the power of 2: ').strip())
					print('2 ^ ', power, ' = ', 2**power)
					_A						=			solution(power)
					print('Sum of the digits is: ', result)






