Untitled

Run Settings
LanguageJava
Language Version
Run Command
import java.util.Queue; import java.util.List; import java.util.ArrayList; import java.util.PriorityQueue; import java.util.LinkedList; class Node { public String value=null; public Node left=null; public Node right=null; public Node(String value){ this.value = value; } } class BinarySearchTree{ private Node root; public BinarySearchTree(String value){ root = new Node(value); } public List<String> bfs(){ Queue<Node> nodesQueue = new LinkedList<Node>(); nodesQueue.add(root); Node current= null; List<String> nodesList= new ArrayList<String>(); while (!nodesQueue.isEmpty()){ current= nodesQueue.remove(); nodesList.add(current.value); if (current.left!= null){ nodesQueue.add(current.left); } if (current.right != null){ nodesQueue.add(current.right); } } return nodesList; } public boolean searchDFS(){ return false; } } class Main { public static void main(String[] args) { BinarySearchTree bst= new BinarySearchTree("1"); bst.bfs(); } }
Editor Settings
Theme
Key bindings
Full width
Lines