content: import java.util.LinkedList;
  import java.util.Queue;
  
  class TreeNode {
      int data;
      TreeNode left;
      TreeNode right;
  
      public TreeNode(int data) {
          this.data = data;
          this.left = null;
          this.right = null;
      }
  }
  
  public class BSTBFS {
      public static void bfs(TreeNode root) {
          if (root == null) {
              return;
          }
  
          Queue<TreeNode> queue = new LinkedList<>();
          queue.offer(root);
  
          while (!queue.isEmpty()) {
              TreeNode current = queue.poll();
              System.out.print(current.data + " ");
  
              if (current.left != null) {
                  queue.offer(current.left);
              }
  
              if (current.right != null) {
                  queue.offer(current.right);
              }
          }
      }
  
      public static void main(String[] args) {
          TreeNode root = new TreeNode(5);
          root.left = new TreeNode(3);
          root.right = new TreeNode(8);
          root.left.left = new TreeNode(2);
          root.left.right = new TreeNode(4);
          root.right.left = new TreeNode(6);
          root.right.right = new TreeNode(9);
  
          System.out.println("Breadth-First Search (BFS) of the BST:");
          bfs(root);
      }
  }
  