Class TreeNode<T>

java.lang.Object
com.amritpandey23.dsalibrary.tree.TreeNode<T>
Type Parameters:
T - the type of the value stored in the tree node

public class TreeNode<T> extends Object
Represents a node in a binary tree structure with a generic value and pointers to the left and right child nodes.
  • Field Details

    • val

      public T val
      The value stored in this tree node.
    • left

      public TreeNode<T> left
      Pointer to the left child node.
  • Constructor Details

    • TreeNode

      public TreeNode(T val)
      Constructs a tree node with a specified value and no children.
      Parameters:
      val - the value to be stored in this tree node
    • TreeNode

      public TreeNode(T val, TreeNode<T> left, TreeNode<T> right)
      Constructs a tree node with a specified value, left child, and right child.
      Parameters:
      val - the value to be stored in this tree node
      left - the left child node
      right - the right child node