





'''simple docstring'''

from __future__ import annotations

__lowerCamelCase : Union[str, Any]											=			10







def 							UpperCAmelCase_    (	lowerCAmelCase_							):

				"""simple docstring"""






				lowercase         = 1
				lowercase         = max(lowerCAmelCase_							)
				while placement <= max_digit:
								# declare and initialize empty buckets
								lowercase         = [[] for _ in range(lowerCAmelCase_							)]
								# split list_of_ints between the buckets
								for i in list_of_ints:
												lowercase         = int((i / placement) % RADIX							)
												buckets[tmp].append(lowerCAmelCase_							)
								# put each buckets' contents into list_of_ints
								lowercase         = 0
								for b in range(lowerCAmelCase_							):
												for i in buckets[b]:
																lowercase         = i
																a += 1
        # move to next
								placement *= RADIX
				return list_of_ints


if __name__ == "__main__":
			import doctest

			doctest.testmod()











'''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       UpperCAmelCase :
		UpperCAmelCase					:	int
		UpperCAmelCase					:	Node | None 			=		None
		UpperCAmelCase					:	Node | None 			=		None







def 							UpperCAmelCase_    (	):

				"""simple docstring"""






				lowercase         = Node(1							)
				lowercase         = Node(2							)
				lowercase         = Node(3							)
				lowercase         = Node(4							)
				lowercase         = Node(5							)
				return tree







def 							UpperCAmelCase_    (	lowerCAmelCase_							):

				"""simple docstring"""






				return [root.data, *preorder(root.left							), *preorder(root.right							)] if root else []







def 							UpperCAmelCase_    (	lowerCAmelCase_							):

				"""simple docstring"""






				return postorder(root.left							) + postorder(root.right							) + [root.data] if root else []







def 							UpperCAmelCase_    (	lowerCAmelCase_							):

				"""simple docstring"""






				return [*inorder(root.left							), root.data, *inorder(root.right							)] if root else []







def 							UpperCAmelCase_    (	lowerCAmelCase_							):

				"""simple docstring"""






				return (max(height(root.left							)		,							height(root.right							)							) + 1) if root else 0







def 							UpperCAmelCase_    (	lowerCAmelCase_							):

				"""simple docstring"""






				lowercase         = []

				if root is None:
								return output

				lowercase         = deque([root]							)

				while process_queue:
								lowercase         = 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_    (	lowerCAmelCase_		,							lowerCAmelCase_							):

				"""simple docstring"""






				lowercase         = []

				def populate_output(lowerCAmelCase_		,							lowerCAmelCase_							) -> 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(lowerCAmelCase_		,							lowerCAmelCase_							)
				return output







def 							UpperCAmelCase_    (	lowerCAmelCase_		,							lowerCAmelCase_							):

				"""simple docstring"""






				lowercase         = []

				def populate_output(lowerCAmelCase_		,							lowerCAmelCase_							) -> 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(lowerCAmelCase_		,							lowerCAmelCase_							)
				return output







def 							UpperCAmelCase_    (	lowerCAmelCase_							):

				"""simple docstring"""






				if root is None:
								return []

				lowercase         = []

				lowercase         = 0
				lowercase         = height(lowerCAmelCase_							)

				for h in range(1		,							height_tree + 1							):
								if not flag:
												output.append(get_nodes_from_left_to_right(lowerCAmelCase_		,							lowerCAmelCase_							)							)
												lowercase         = 1
								else:
												output.append(get_nodes_from_right_to_left(lowerCAmelCase_		,							lowerCAmelCase_							)							)
												lowercase         = 0

				return output







def 							UpperCAmelCase_    (	):  # Main function for testing.

				"""simple docstring"""






				lowercase         = make_tree()
				print(f'In-order Traversal: {inorder(lowerCAmelCase_							)}'							)
				print(f'Pre-order Traversal: {preorder(lowerCAmelCase_							)}'							)
				print(f'Post-order Traversal: {postorder(lowerCAmelCase_							)}'		,							"\n"							)

				print(f'Height of Tree: {height(lowerCAmelCase_							)}'		,							"\n"							)

				print("Complete Level Order Traversal: "							)
				print(level_order(lowerCAmelCase_							)		,							"\n"							)

				print("Level-wise order Traversal: "							)

				for level in range(1		,							height(lowerCAmelCase_							) + 1							):
								print(f'Level {level}:'		,							get_nodes_from_left_to_right(lowerCAmelCase_		,							level=lowerCAmelCase_							)							)

				print("\nZigZag order Traversal: "							)
				print(zigzag(lowerCAmelCase_							)							)


if __name__ == "__main__":
			import doctest

			doctest.testmod()
			main()




