All content related to binary-tree Find Left View of a Binary Tree

Write a program to find the left view of the given binary tree. The left view of a binary tree is a group of nodes visible when viewed from the left side or when the tree is visited from the left side. Binary Indexed Tree or Fenwick Tree

A Fenwick tree or Binary indexed tree is a data structure that can efficiently update elements and calculate prefix sums in a table of numbers. Boris Ryabko proposed this structure in 1989, with a further modification published in 1992. Find k'th largest element in a BST

Given the root of a binary search tree and an integer k, write a program to return the kth largest value of all the values of the nodes in the tree. Minimum absolute difference in BST

Given the root of a Binary Search Tree (BST), write a program to return the absolute minimum difference between the values of any two nodes in the tree. Find the Maximum Depth or Height of a Tree

Given a binary tree, write a program to find the height of it. A binary tree's height or depth is the total number of nodes or edges on the longest path from the root node to the leaf node. Merge Two Binary Tree

Given two binary trees, merge them into a new binary tree such that if two nodes overlap then add them and put them into the new tree at the same location else put the non-NULL node in the new tree. Introduction to Heap Data Structure

A heap is a complete binary tree structure where each element satisfies a heap property. We learn two types of the heap in programming: 1) max-heap, which satisfies max heap property 2) min-heap, which satisfies min heap property. Find Min Depth of a Binary Tree

Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node. The path has to end on a leaf node. Recursive Tree Traversals of a Binary Tree: Preorder, Inorder and Postorder Traversal

To process data stored in a binary tree, we need to traverse each tree node, and the process to visit all nodes is called binary tree traversal. In this blog, we will be discussing three popular recursive tree traversals: preorder, inorder and postorder traversals. These traversals are also called depth-first search traversal or dfs traversal in data structures. Iterative Binary Tree Traversal using Stack: Preorder, Inorder and Postorder

In recursive DFS traversals of a binary tree, we have three basic elements to traverse— root, left subtree, and right subtree. The traversal order depends on the order in which we process the root node. Here recursive code is simple and easy to visualize — only one function parameter and 3–4 lines of code. So critical question would be — How can we convert it into iterative code using stack? To simulate the recursive traversal into an iterative traversal, we need to understand the flow of recursive calls. Level Order Traversal of a Binary Tree :  Breadth First Search

Level order traversal accesses nodes in level by level order. This is also called breadth-first search traversal or BFS traversal. Here we start from the root node and process it, then process all the nodes at the first level, then process all the nodes at the second level, and so on. In other words, we explore all nodes at the current level before moving on to the nodes at the next level.