Quick actions

cmd+k|ctrl+k

Navigation

Languages

Searching algorithms

Snippet info

Language

Java

Visibility

public

Author

ingserge

Created

2025-01-21T16:55:48.557099Z

Updated

2025-01-21T16:55:48.557099Z

class Node{
    private int value=0;
    private Node left;
    private Node right;
    
    public Node(int value){
        this.value= value;
    }
    
    public void setValue(int value){
        this.value=value;    
    }
    public int getValue(){
        return this.value;
    }
    
    public Node getRigh(){
        return this.lrigth;
    }
    public void setRigth(){}
}

class Searching{
    
    public Searching(){
    }
    /**
     * 
        Shortest Path
        
        + Closer Nodes
        - More memory
        
        Use cases:
        
        If having add info (upper,lower) if on upper is better else dfs
        Solution not far from the root
        Tree is very deep and solution rare (DFS will take a lot of time, due to recursion but memory concerns)
        Finding shortest path
        
    **/
    public int bfs(Node root){
        
    }
    
    /**
     * 
     * Does path exist?
     * + Less MEmory
     * + Used Node is lower levels
     
     * - Can Get slow
     * 
     * Use Cases
     * 
     * If the tree is very wide, since BFS will need too much memory
     * Solutions frequent but located deep in the tree
     * Determining path exists
     * 
     **/
    public int dfs(Node node){
        
    }
    
}

class Main {
    public static void main(String[] args) {
        Node root = new Node(9);
        
        root.
        
    }
}
INFO