Meetalistudayyy.hashnode.dev·Jun 30, 2024Why These Trees Won't Save Your Life, But Might Save Your Job!If you have already guessed that it's the topic Trees, then congratulations! Apparently, you and I share the same kind of humor! Data Structures and Algorithms (DSA) have a lot to offer, and one of the most important topics is "Trees". If only people...DiscussTrees
Vineeth Chivukulavineethchivukula.hashnode.dev·Jun 25, 2024Understanding Tree Depth-First SearchTree DFS (Depth-First Search) is a traversal technique used in tree data structures that explores each branch as far as possible before backtracking. This technique can be implemented using recursion or an explicit stack data structure. There are thr...DiscussDFS
Vineeth Chivukulavineethchivukula.hashnode.dev·Jun 25, 2024Understanding Tree Breadth-First SearchTree BFS (Breadth-First Search) is a traversal technique used in tree data structures that explores all the nodes at the present depth level before moving on to nodes at the next depth level. This technique is often implemented using a queue data str...DiscussBFS
Abhilietcode.hashnode.dev·Jun 23, 2024Binary Tree Maximum Path Sum (Hard)A path in a binary tree is a sequence of nodes where each pair of adjacent nodes in the sequence has an edge connecting them. A node can only appear in the sequence at most once. Note that the path does not need to pass through the root. The path sum...DiscussTreesTree
Abhilietcode.hashnode.dev·Jun 23, 2024Kth Smallest Element in a BST (Medium)Given the root of a binary search tree, and an integer k, return the k<sup>th</sup> smallest value (1-indexed) of all the values of the nodes in the tree. Example 1: Input: root = [3,1,4,null,2], k = 1 Output: 1 Example 2: Input: root = [5,3,6,2,4...DiscussTreesTree
Abhilietcode.hashnode.dev·Jun 23, 2024Sum of Nodes with Even-Valued Grandparent (Medium)Given the root of a binary tree, return the sum of values of nodes with an even-valued grandparent. If there are no nodes with an even-valued grandparent, return 0. A grandparent of a node is the parent of its parent if it exists. Example 1: Input: ...DiscussTreesTree
Abhilietcode.hashnode.dev·Jun 23, 2024Sum Root to Leaf Numbers (Medium)You are given the root of a binary tree containing digits from 0 to 9 only. Each root-to-leaf path in the tree represents a number. For example, the root-to-leaf path 1 -> 2 -> 3 represents the number 123. Return the total sum of all root-to-leaf n...DiscussTreesTree
Abhilietcode.hashnode.dev·Jun 23, 2024Validate Binary Search TreeGiven the root of a binary tree, determine if it is a valid binary search tree (BST). A valid BST is defined as follows: The left subtree of a node contains only nodes with keys less than the node's key. The right subtree of a node contains only no...DiscussTreesTree
Abhilietcode.hashnode.dev·Jun 23, 2024Count Good Nodes in Binary TreeGiven a binary tree root, a node X in the tree is named good if in the path from root to X there are no nodes with a value greater than X. Return the number of good nodes in the binary tree. Example 1: Input: root = [3,1,4,3,null,1,5] Output: 4 Expl...DiscussTreesTree
Abhilietcode.hashnode.dev·Jun 23, 2024Binary Tree Right Side View (Medium)Given the root of a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom. Example 1: Input: root = [1,2,3,null,5,null,4] Output: [1,3,4] Example 2: Input: root = [1,n...DiscussTreesTree