


from __future__ import annotations


class   a__	:

       def __init__(   self      :     Dict      ,							lowerCamelCase_      :     int    ):
            a_    :     int										=    data
            a_    :     Node | None										=    None
            a_    :     Node | None										=    None



def  _a			(						__UpperCamelCase ):  # In Order traversal of the tree






     if tree:
          display(tree.left )
          print(tree.data )
          display(tree.right )



def  _a			(						__UpperCamelCase ):
     return 1 + max(depth_of_tree(tree.left )  ,  depth_of_tree(tree.right ) ) if tree else 0



def  _a			(						__UpperCamelCase ):






     if not tree:
          return True
     if tree.left and tree.right:
          return is_full_binary_tree(tree.left ) and is_full_binary_tree(tree.right )
     else:
          return not tree.left and not tree.right



def  _a			(						):  # Main function for testing.
     a_    :     Optional[int]										=    Node(1 )
     a_    :     Optional[Any]										=    Node(2 )
     a_    :     List[Any]										=    Node(3 )
     a_    :     int										=    Node(4 )
     a_    :     str										=    Node(5 )
     a_    :     List[Any]										=    Node(6 )
     a_    :     Any										=    Node(7 )
     a_    :     List[str]										=    Node(8 )
     a_    :     Dict										=    Node(9 )

     print(is_full_binary_tree(a_ ) )
     print(depth_of_tree(a_ ) )
     print("""Tree is: """ )
     display(a_ )


if __name__ == "__main__":
 main()







from heapq import heappop, heappush

import numpy as np



def  _a			(						__UpperCamelCase  ,  __UpperCamelCase  ,  __UpperCamelCase  ,  __UpperCamelCase  ,  ):
     a_			,			a_    :     Any										=    grid.shape
     a_    :     Dict										=    [-1, 1, 0, 0]
     a_    :     List[Any]										=    [0, 0, -1, 1]
     if allow_diagonal:
          dx += [-1, -1, 1, 1]
          dy += [-1, 1, -1, 1]

     a_			,			a_    :     int										=    [(0, source)], set()
     a_    :     Optional[Any]										=    np.full((rows, cols)  ,  np.inf )
     a_    :     Tuple										=    0
     a_    :     Optional[Any]										=    np.empty((rows, cols)  ,  dtype=__UpperCamelCase )
     a_    :     Optional[Any]										=    None

     while queue:
          ((a_)			,			(a_))    :     Any										=    heappop(__UpperCamelCase )
          if (x, y) in visited:
               continue
          visited.add((x, y) )

          if (x, y) == destination:
               a_    :     Tuple										=    []
               while (x, y) != source:
                    path.append((x, y) )
                    a_			,			a_    :     Any										=    predecessors[x, y]
               path.append(__UpperCamelCase )  # add the source manually
               path.reverse()
               return matrix[destination], path

          for i in range(len(__UpperCamelCase ) ):
               a_			,			a_    :     Dict										=    x + dx[i], y + dy[i]
               if 0 <= nx < rows and 0 <= ny < cols:
                    a_    :     List[Any]										=    grid[nx][ny]
                    if next_node == 1 and matrix[nx, ny] > dist + 1:
                         heappush(__UpperCamelCase  ,  (dist + 1, (nx, ny)) )
                         a_    :     List[str]										=    dist + 1
                         a_    :     Union[str, Any]										=    (x, y)

     return np.inf, []


if __name__ == "__main__":
       import doctest

       doctest.testmod()



