parameters: (root)
docstring: Map mp contains:
          [0] -> 1
          [1] -> 2
          [2] -> 4
          [3] -> 8
docstring_summary: Map mp contains:
          [0] -> 1
          [1] -> 2
          [2] -> 4
          [3] -> 8
docstring_tokens: Map mp contains : [ 0 ] - > 1 [ 1 ] - > 2 [ 2 ] - > 4 [ 3 ] - > 8
function: def leftView(root):
      if root is None:
          return
  
      # initialising variables
      q = queue.Queue()
      q.put(root)
      root.level = 0
      mp = {}
  
      # variable to store level of nodes
      level = 0
  
      # asigning level to each node of Binary Tree 
      # storing first node of same level in a map
      # with key as level
      while (not q.empty()):
          # extract and remove the node from the front of queue
          temp = q.get()
          level = temp.level
  
          # make key as level and data as value for map
          if level not in mp:
              mp[level] = temp.data
          
          # when left child exists, assign level to it
          # and push it to the queue
          if temp.left is not None:
              temp.left.level = level + 1
              q.put(temp.left)
  
          # when right child exists, assign level to it
          # and push it to the queue
          if temp.right is not None: 
              temp.right.level = level + 1
              q.put(temp.right)
      '''
          Map mp contains:
          [0] -> 1
          [1] -> 2
          [2] -> 4
          [3] -> 8
      '''
  
      print("Left View of Binary Tree: ")
      # Iterate over the map keys i.e 0, 1, 2, 3
      for key, value in enumerate(sorted(mp)):
          print(mp[value], end = " ")
function_tokens: def leftView ( root ) : if root is None : return # initialising variables q = queue . Queue ( ) q . put ( root ) root . level = 0 mp = { } # variable to store level of nodes level = 0 # asigning level to each node of Binary Tree  # storing first node of same level in a map # with key as level while ( not q . empty ( ) ) : # extract and remove the node from the front of queue temp = q . get ( ) level = temp . level # make key as level and data as value for map if level not in mp : mp [ level ] = temp . data # when left child exists, assign level to it # and push it to the queue if temp . left is not None : temp . left . level = level + 1 q . put ( temp . left ) # when right child exists, assign level to it # and push it to the queue if temp . right is not None : temp . right . level = level + 1 q . put ( temp . right ) print ( "Left View of Binary Tree: " ) # Iterate over the map keys i.e 0, 1, 2, 3 for key , value in enumerate ( sorted ( mp ) ) : print ( mp [ value ] , end = " " )