code: def serialize(root):
      def build_string(node):
          if node:
              vals.append(str(node.val))
              build_string(node.left)
              build_string(node.right)
          else:
              vals.append("#")
  
      vals = []
      build_string(root)
      return " ".join(vals)
  
label_desc: Use image node_id 1 for calling a global function with example usage: serialize(root) and returns: str