Binary Search Tree

Populating Next Right Pointers in Each Node

class Solution {
    public Node connect(Node root) {
        Queue<Node> q=new LinkedList<>();
        if(root==null){
            return null;
        }
        q.add(root);
        while(!q.isEmpty()){
          int size=q.size();
          for(int i=1;i<=size;i++){
              Node curr=q.remove();
              if(i==size){
                 curr.next=null; 
              }else{
                 curr.next=q.peek(); 
              }
             
              if(curr.left!=null){
                  q.add(curr.left);
                  q.add(curr.right);
              }
          }   
        }
        
        return root;
    }
}

Binary Tree Level Order Traversal

Search in BST

Search in BST ( recursively )

Insert BST ( Recursively )

Insert in BST ( Iteratively )

Delete in BST

Floor in BST

Ceil in BST

Revisit AVL Tree

Revisit Red Black Tree

TreeSet In java

Add | Contains | Iterator

Add+Remove

Lower | Higher | Floor | Ceiling

TreeMap in Java

Example

HigherKey | LowerKey | FloorKey | CeilingKey

GetValue

Ceiling on left side in an array

Find Kth Smallest in BST

Check for BST

Fix BST with Two Nodes Swapped

Pair Sum with given BST

Vertical Sum in a Binary Tree

Vertical Traversal of Binary Tree

Top View of Binary Tree

Bottom View of Binary Tree

Last updated