

'''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 	lowerCAmelCase  :
       lowerCAmelCase_												=			42
       lowerCAmelCase_												=			None
       lowerCAmelCase_												=			None






def 					__UpperCamelCase				(						):






     '''simple docstring'''





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

def 					__UpperCamelCase				(						lowercase__    :	Node | None			):






     '''simple docstring'''





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

def 					__UpperCamelCase				(						lowercase__    :	Node | None			):






     '''simple docstring'''





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

def 					__UpperCamelCase				(						lowercase__    :	Node | None			):






     '''simple docstring'''





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

def 					__UpperCamelCase				(						lowercase__    :	Node | None			):






     '''simple docstring'''





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

def 					__UpperCamelCase				(						lowercase__    :	Node | None			):






     '''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				(						lowercase__    :	Node | None,       lowercase__    :	int			):






     '''simple docstring'''





     __lowercase      		=[]

     def populate_output(lowercase__    :	Node | None,       lowercase__    :	int			) -> 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(lowercase__,       lowercase__			)
     return output

def 					__UpperCamelCase				(						lowercase__    :	Node | None,       lowercase__    :	int			):






     '''simple docstring'''





     __lowercase      		=[]

     def populate_output(lowercase__    :	Node | None,       lowercase__    :	int			) -> 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(lowercase__,       lowercase__			)
     return output

def 					__UpperCamelCase				(						lowercase__    :	Node | None			):






     '''simple docstring'''





     if root is None:
          return []

     __lowercase      		=[]

     __lowercase      		=0
     __lowercase      		=height(lowercase__			)

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

     return output

def 					__UpperCamelCase				(						):  # Main function for testing.






     '''simple docstring'''





     __lowercase      		=make_tree()
     print(F'''In-order Traversal: {inorder(lowercase__			)}'''			)
     print(F'''Pre-order Traversal: {preorder(lowercase__			)}'''			)
     print(F'''Post-order Traversal: {postorder(lowercase__			)}''',       '\n'			)

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

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

     print('Level-wise order Traversal: '			)

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

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


if __name__ == "__main__":
       import doctest

       doctest.testmod()
       main()





'''simple docstring'''

# Function to print upper half of diamond (pyramid)

def 					__UpperCamelCase				(						lowercase__    :	Optional[Any]			):






     '''simple docstring'''





     for i in range(0,       lowercase__			):
          for _ in range(0,       n - i - 1			):  # printing spaces
               print(' ',       end=''			)
          for _ in range(0,       i + 1			):  # printing stars
               print('* ',       end=''			)
          print()

def 					__UpperCamelCase				(						lowercase__    :	Optional[Any]			):






     '''simple docstring'''





     for i in range(lowercase__,       0,       -1			):
          for _ in range(lowercase__,       0,       -1			):  # printing stars
               print('* ',       end=''			)
          print()
          for _ in range(n - i + 1,       0,       -1			):  # printing spaces
               print(' ',       end=''			)

def 					__UpperCamelCase				(						lowercase__    :	Any			):






     '''simple docstring'''





     if n <= 0:
          print('       ...       ....        nothing printing :('			)
          return
     floyd(lowercase__			)  # upper half
     reverse_floyd(lowercase__			)  # lower half


if __name__ == "__main__":
       print(r'''| /\ | |- |  |-  |--| |\  /| |-''')
       print(r'''|/  \| |- |_ |_  |__| | \/ | |_''')
       UpperCAmelCase					 =	1
       while K:
              UpperCAmelCase					 =	int(input('''enter the number and , and see the magic : '''))
              print()
              pretty_print(user_number)
              UpperCAmelCase					 =	int(input('''press 0 to exit... and 1 to continue...'''))

       print('''Good Bye...''')


