code: 
  
  
  
  
  
  
  from __future__ import annotations
  
  from collections import defaultdict
  from dataclasses import dataclass
  
  
  
  
  
  
  
  @dataclass
  class 							UpperCAmelCase_     :
       __lowerCamelCase										=     42
       __lowerCamelCase										=     None
       __lowerCamelCase										=     None
  
  
  
  
  
  def    _lowerCamelCase	(	)   -> TreeNode:
  
       '''simple docstring'''
       return TreeNode(3   ,       TreeNode(9					)   ,       TreeNode(20   ,       TreeNode(15					)   ,       TreeNode(7					)					)					)
  
  
  
  
  
  def    _lowerCamelCase	(	__lowerCamelCase					)   -> list[int]:
  
       '''simple docstring'''
  
       def depth_first_search(
           __lowerCamelCase   ,       __lowerCamelCase   ,       __lowerCamelCase					) -> None:
            if not root:
                 return
  
            if depth == len(__lowerCamelCase					):
                 right_view.append(root.val					)
  
            depth_first_search(root.right   ,       depth + 1   ,       __lowerCamelCase					)
            depth_first_search(root.left   ,       depth + 1   ,       __lowerCamelCase					)
  
       UpperCAmelCase__			:     list										= []
       if not root:
            return right_view
  
       depth_first_search(__lowerCamelCase   ,       0   ,       __lowerCamelCase					)
       return right_view
  
  
  
  
  
  def    _lowerCamelCase	(	__lowerCamelCase					)   -> list[int]:
  
       '''simple docstring'''
  
       def depth_first_search(
           __lowerCamelCase   ,       __lowerCamelCase   ,       __lowerCamelCase					) -> None:
            if not root:
                 return
  
            if depth == len(__lowerCamelCase					):
                 left_view.append(root.val					)
  
            depth_first_search(root.left   ,       depth + 1   ,       __lowerCamelCase					)
            depth_first_search(root.right   ,       depth + 1   ,       __lowerCamelCase					)
  
       UpperCAmelCase__			:     list										= []
       if not root:
            return left_view
  
       depth_first_search(__lowerCamelCase   ,       0   ,       __lowerCamelCase					)
       return left_view
  
  
  
  
  
  def    _lowerCamelCase	(	__lowerCamelCase					)   -> list[int]:
  
       '''simple docstring'''
  
       def breadth_first_search(__lowerCamelCase   ,       __lowerCamelCase					) -> None:
            UpperCAmelCase__			:     List[str]										= [(root, 0)]
            UpperCAmelCase__			:     Optional[Any]										= defaultdict(__lowerCamelCase					)
  
            while queue:
                 UpperCAmelCase__			:     Union[str, Any]										= queue.pop(0					)
                 UpperCAmelCase__			,		UpperCAmelCase__			:     Tuple										= first
  
                 lookup[hd].append(node.val					)
  
                 if node.left:
                      queue.append((node.left, hd - 1)					)
                 if node.right:
                      queue.append((node.right, hd + 1)					)
  
            for pair in sorted(lookup.items()   ,       key=lambda __lowerCamelCase					: each[0]					):
                 top_view.append(pair[1][0]					)
  
       UpperCAmelCase__			:     list										= []
       if not root:
            return top_view
  
       breadth_first_search(__lowerCamelCase   ,       __lowerCamelCase					)
       return top_view
  
  
  
  
  
  def    _lowerCamelCase	(	__lowerCamelCase					)   -> list[int]:
  
       '''simple docstring'''
       from collections import defaultdict
  
       def breadth_first_search(__lowerCamelCase   ,       __lowerCamelCase					) -> None:
            UpperCAmelCase__			:     Any										= [(root, 0)]
            UpperCAmelCase__			:     Optional[int]										= defaultdict(__lowerCamelCase					)
  
            while queue:
                 UpperCAmelCase__			:     Union[str, Any]										= queue.pop(0					)
                 UpperCAmelCase__			,		UpperCAmelCase__			:     List[Any]										= first
                 lookup[hd].append(node.val					)
  
                 if node.left:
                      queue.append((node.left, hd - 1)					)
                 if node.right:
                      queue.append((node.right, hd + 1)					)
  
            for pair in sorted(lookup.items()   ,       key=lambda __lowerCamelCase					: each[0]					):
                 bottom_view.append(pair[1][-1]					)
  
       UpperCAmelCase__			:     list										= []
       if not root:
            return bottom_view
  
       breadth_first_search(__lowerCamelCase   ,       __lowerCamelCase					)
       return bottom_view
  
  
  if __name__ == "__main__":
        import doctest
  
        doctest.testmod()
  
  
  
  
  
  
  
style_context: 
  
  
  
  
  
  
  import math
  import os
  
  import cva
  import numpy as np
  
  SCREAMING_SNAKE_CASE__		:       Optional[Any]   							=							255.0
  
  
  
  
  
  def    _lowerCamelCase	(	__lowerCamelCase   ,       __lowerCamelCase					)   -> float:
  
       '''simple docstring'''
       UpperCAmelCase__			:     List[Any]										= np.mean((original - contrast) ** 2					)
       if mse == 0:
            return 100
  
       return 20 * math.logaa(PIXEL_MAX / math.sqrt(__lowerCamelCase					)					)
  
  
  
  
  
  def    _lowerCamelCase	(	)   -> None:
  
       '''simple docstring'''
       UpperCAmelCase__			:     Union[str, Any]										= os.path.dirname(os.path.realpath(__lowerCamelCase					)					)
       # Loading images (original image and compressed image)
       UpperCAmelCase__			:     List[Any]										= cva.imread(os.path.join(__lowerCamelCase   ,       """image_data/original_image.png"""					)					)
       UpperCAmelCase__			:     Dict										= cva.imread(os.path.join(__lowerCamelCase   ,       """image_data/compressed_image.png"""					)   ,       1					)
  
       UpperCAmelCase__			:     Tuple										= cva.imread(os.path.join(__lowerCamelCase   ,       """image_data/PSNR-example-base.png"""					)					)
       UpperCAmelCase__			:     int										= cva.imread(
           os.path.join(__lowerCamelCase   ,       """image_data/PSNR-example-comp-10.jpg"""					)   ,       1					)
  
       # Value expected: 29.73dB
       print("""-- First Test --"""					)
       print(F"PSNR value is {peak_signal_to_noise_ratio(__lowerCamelCase   ,       __lowerCamelCase					)} dB"					)
  
       # # Value expected: 31.53dB (Wikipedia Example)
       print("""\n-- Second Test --"""					)
       print(F"PSNR value is {peak_signal_to_noise_ratio(__lowerCamelCase   ,       __lowerCamelCase					)} dB"					)
  
  
  if __name__ == "__main__":
        main()
  
  
  
  
  
  
  