# Tree

## LeetCode 226 | Invert Binary Tree | Python | Solution

Invert Binary Tree is one of the most popular programming problems. It’s an easy problem. I assume that you have a basic understanding of Binary Tree and Recursion. LeetCode 226 The problem description is straightforward. Simply put, we have to invert a binary tree and then return the root. More precisely, to solve this, we […]

## LeetCode 199 | Binary Tree Right Side View | Python | Solution

If you know about the level order traversal algorithm, finding the right-side view of a binary tree becomes easy for you. This problem is nothing but a simple extended version of that. If you want to know about Level Order Traversal, I will encourage you to read this blog. LeetCode 199 The problem description is

## Binary Search Tree | Data Structure

Before getting into the Binary Search Tree (BST), you have to know the basics of Tree and Binary Tree. I assume that you have the basic idea of Tree and Binary Tree. Intro A Binary Search Tree is a special type of Binary Tree with some extra conditions. In a binary tree, a node can

## Same Tree | LeetCode 100 | Python | Solution

LeetCode 100 It’s an easy LeetCode problem, and the description is concise and straightforward. We can solve this problem using the DFS algorithm. From two binary trees, we have to check whether both are the same or not. Consider the following cases for two different nodes. If both nodes are null, we can say that

## Kth Smallest Element in a BST | LeetCode 230 | Python | Solution

LeetCode 230 I hope you already know about Binary Search Tree. In BST, each node is greater than its left subtree and smaller than its right subtree. If we print all the nodes of a BST using an inorder traversal algorithm, we will get the sorted value in ascending order. Inorder traversal follows the rule:

## Binary Tree Level Order Traversal | LeetCode 102 | Python | Solution

LeetCode 102 This problem just simply the implementation of the level order traversal algorithm. If you don’t know about level order traversal yet, you can check my blog on this topic. As we know, using level order traversal, we traverse through the tree level by level. But in this problem, we have to separate values

## Maximum Depth of Binary Tree | LeetCode 104 | Python | Solution

LeetCode 104 It’s a common and basic type of problem. The problem title is self-explanatory. We all know about a binary tree. To solve this problem, we have to find the maximum depth of a binary tree. We can solve this using both DFS and BFS algorithms. I am going to use the DFS solution.

## Level Order Traversal – BFS Algorithm

This one is another way of traversing through a binary tree. There are many other ways you can do it. Click here to check. Level order traversal is a binary tree version of the BFS (Breadth-First Search) algorithm. The concept is simple. I hope you already know about the binary tree. If we visualize a

## Binary Tree Traversal Algorithms | DFS | Algorithm

There are three Depth First Search (DFS) types of traversal algorithms for Binary Tree. Traversal algorithms are for traversing in a Binary Tree. These three are variations of the Depth First Search (DFS) algorithm. In DFS, we start traversing from the root and go in-depth until there is no node to traverse. Its uses in

## Binary Tree | Data Structure

I have written a blog about the tree data structure overview. If you don’t know about tree data structure, click here to see my blog. In this blog, we will be going to know about Binary Tree. I hope you will get some idea of it. A binary tree is a type of tree. But

Scroll to Top