Diameter of a Binary Tree | Trees
In this video, I have discussed how to calculate diameter of a binary tree with O(n) time complexity and O(1) space complexity.
The diameter of a binary tree is the length of the longest path between any two nodes in a tree. This path may or may not pass through the root.
Source code: https://github.com/fit-coder/fitcoderyoutube/tree/master/tree
00:00 Introduction
00:06 Definition of Diameter
01:48 Pseudo Code
10:01 C++ Implementation
-------------------------------------------------------------
I live in New Delhi and love explaining programming concepts. I have done M.Tech(BITS Pilani) + B.Tech(PEC, Chandigarh) in Computer Science and am currently working as a software engineer in a MNC.
If you like my content, please like, share my videos and subscribe to the channel.
-------------------------------------------------------------
For other tree tutorials, please refer to the below links:
Introduction to Trees: https://youtu.be/sAtplKUhtQ8
Binary Trees: https://youtu.be/2edIhwsnqBY&t=8s
Binary Tree Traversals: https://youtu.be/p3YUlEZr2vM&t=64s
Shortcut trick for Binary Tree Traversals: https://youtu.be/Y-FcfdAWd8Q
Inorder Traversal Iterative: https://youtu.be/_4Jhejxvttc
Preorder Traversal Iterative: https://youtu.be/RDG4jtLGDmo
Postorder Traversal Iterative (2 stack method): https://youtu.be/4VpO4lrRINc
Postorder Traversal Iterative (1 stack method): https://youtu.be/Zv14sK2kvtQ
Level Order Traversal: https://youtu.be/lXIk1PXb1Jc
Morris Inorder Traversal: https://youtu.be/BuI-EULsz0Y
Zigzag Level Order Traversal: https://youtu.be/YwABW6q3DOM
Binary Tree From Inorder and Preorder (Recursive): https://youtu.be/FBaSrNSf9po
Binary Tree From Inorder and Preorder (Iterative): https://youtu.be/LVFYyw7rZb8
Binary Tree From Inorder and Postorder (Recursive):https://youtu.be/rY9ejIY9Osw
Binary Tree From Inorder and Postorder (Iterative):https://youtu.be/8cUuA066lZQ
Binary Tree From Inorder and Levelorder: https://youtu.be/7eBndROfUnw
Binary Tree From Preorder and Postorder: https://youtu.be/LnHSOy7ctms
Height of a Binary Tree (Recursive): https://youtu.be/9ejFkjEgK3k
Height of a Binary Tree (Iterative): https://youtu.be/OUhTI4dtQbY&t=385s
Diameter of a Binary Tree: https://youtu.be/Prph-j0sgr4
Lowest Common Ancestor: https://youtu.be/k7NF6rNOs4Y
Left View and Right View (Recursive): https://youtu.be/3Qjm1iX5dw8
Left View and Right View (Iterative): https://youtu.be/ruT7rVIveqA
Top View and Bottom View (Recursive): https://youtu.be/zoagmWU1yD8
Top View and Bottom View (Iterative): https://youtu.be/=-Cr4I8ZTXgc
Boundary Traversal: https://youtu.be/0nx-t0PcccA
For in-depth Graph theory and implementation details, please refer to the below playlist:
https://youtu.be/4xMsNIPEkwA&list=PLFj4kIJmwGu3m30HfYDDufr3PZBfyngr0
#DataStructure,#Trees,#FitCoder,#Algorithm,#competitiveprogramming,#binarytree
Видео Diameter of a Binary Tree | Trees канала Fit Coder
The diameter of a binary tree is the length of the longest path between any two nodes in a tree. This path may or may not pass through the root.
Source code: https://github.com/fit-coder/fitcoderyoutube/tree/master/tree
00:00 Introduction
00:06 Definition of Diameter
01:48 Pseudo Code
10:01 C++ Implementation
-------------------------------------------------------------
I live in New Delhi and love explaining programming concepts. I have done M.Tech(BITS Pilani) + B.Tech(PEC, Chandigarh) in Computer Science and am currently working as a software engineer in a MNC.
If you like my content, please like, share my videos and subscribe to the channel.
-------------------------------------------------------------
For other tree tutorials, please refer to the below links:
Introduction to Trees: https://youtu.be/sAtplKUhtQ8
Binary Trees: https://youtu.be/2edIhwsnqBY&t=8s
Binary Tree Traversals: https://youtu.be/p3YUlEZr2vM&t=64s
Shortcut trick for Binary Tree Traversals: https://youtu.be/Y-FcfdAWd8Q
Inorder Traversal Iterative: https://youtu.be/_4Jhejxvttc
Preorder Traversal Iterative: https://youtu.be/RDG4jtLGDmo
Postorder Traversal Iterative (2 stack method): https://youtu.be/4VpO4lrRINc
Postorder Traversal Iterative (1 stack method): https://youtu.be/Zv14sK2kvtQ
Level Order Traversal: https://youtu.be/lXIk1PXb1Jc
Morris Inorder Traversal: https://youtu.be/BuI-EULsz0Y
Zigzag Level Order Traversal: https://youtu.be/YwABW6q3DOM
Binary Tree From Inorder and Preorder (Recursive): https://youtu.be/FBaSrNSf9po
Binary Tree From Inorder and Preorder (Iterative): https://youtu.be/LVFYyw7rZb8
Binary Tree From Inorder and Postorder (Recursive):https://youtu.be/rY9ejIY9Osw
Binary Tree From Inorder and Postorder (Iterative):https://youtu.be/8cUuA066lZQ
Binary Tree From Inorder and Levelorder: https://youtu.be/7eBndROfUnw
Binary Tree From Preorder and Postorder: https://youtu.be/LnHSOy7ctms
Height of a Binary Tree (Recursive): https://youtu.be/9ejFkjEgK3k
Height of a Binary Tree (Iterative): https://youtu.be/OUhTI4dtQbY&t=385s
Diameter of a Binary Tree: https://youtu.be/Prph-j0sgr4
Lowest Common Ancestor: https://youtu.be/k7NF6rNOs4Y
Left View and Right View (Recursive): https://youtu.be/3Qjm1iX5dw8
Left View and Right View (Iterative): https://youtu.be/ruT7rVIveqA
Top View and Bottom View (Recursive): https://youtu.be/zoagmWU1yD8
Top View and Bottom View (Iterative): https://youtu.be/=-Cr4I8ZTXgc
Boundary Traversal: https://youtu.be/0nx-t0PcccA
For in-depth Graph theory and implementation details, please refer to the below playlist:
https://youtu.be/4xMsNIPEkwA&list=PLFj4kIJmwGu3m30HfYDDufr3PZBfyngr0
#DataStructure,#Trees,#FitCoder,#Algorithm,#competitiveprogramming,#binarytree
Видео Diameter of a Binary Tree | Trees канала Fit Coder
Показать
Комментарии отсутствуют
Информация о видео
Другие видео канала
![Binary tree traversal: Preorder, Inorder, Postorder](https://i.ytimg.com/vi/gm8DUJJhmY4/default.jpg)
![Postorder Traversal of Binary Tree Using Two Stacks | Iterative Postorder Traversal of Binary Tree](https://i.ytimg.com/vi/4VpO4lrRINc/default.jpg)
![14-Year-Old Prodigy Programmer Dreams In Code](https://i.ytimg.com/vi/DBXZWB_dNsw/default.jpg)
![DFS Depth First Search | Graph Traversal | Data Structure](https://i.ytimg.com/vi/oO1857MQlcs/default.jpg)
![Data structures: Introduction to Trees](https://i.ytimg.com/vi/qH6yxkw0u78/default.jpg)
![Topological Sort | Kahn vs DFS | Graphs | Data Structure](https://i.ytimg.com/vi/gDNm1m3G4wo/default.jpg)
![Postorder Traversal of Binary Tree Using One Stack | Iterative Postorder Traversal of Binary Tree](https://i.ytimg.com/vi/Zv14sK2kvtQ/default.jpg)
![Introduction to Trees | Trees Tutorial | Data Structure](https://i.ytimg.com/vi/sAtplKUhtQ8/default.jpg)
![Introduction to Binary Trees | Trees Tutorial | Implementation | Data Structure](https://i.ytimg.com/vi/2edIhwsnqBY/default.jpg)
![BFS Breadth First Search | Graph Traversal | Data Structure](https://i.ytimg.com/vi/iYz-pG1CPIM/default.jpg)
![The first 20 hours -- how to learn anything | Josh Kaufman | TEDxCSU](https://i.ytimg.com/vi/5MgBikgcWnY/default.jpg)
![Binary Tree Traversals | Inorder, Preorder, Postorder | Data Structure](https://i.ytimg.com/vi/p3YUlEZr2vM/default.jpg)
![Add Two Numbers Represented by Linked Lists | Reverse Number](https://i.ytimg.com/vi/4p6-qXTex_w/default.jpg)
![Dinic algorithm | Maximum Flow Problem | Network Flow | Graphs | Data Structure](https://i.ytimg.com/vi/duKIzgJQ1w8/default.jpg)
![Introduction to Graphs Data Structure](https://i.ytimg.com/vi/4xMsNIPEkwA/default.jpg)
![Construct Binary Tree From Inorder and Postorder traversal (Recursive method) | Trees](https://i.ytimg.com/vi/rY9ejIY9Osw/default.jpg)
![Level Order Traversal of Binary Tree | Using recursion | Using Queue](https://i.ytimg.com/vi/lXIk1PXb1Jc/default.jpg)
![This Crazy Tree Grows 40 Kinds of Fruit | National Geographic](https://i.ytimg.com/vi/ik3l4U_17bI/default.jpg)
![Graph Coloring | Chromatic Number | BackTracking | Greedy Algorithm | Data Structure](https://i.ytimg.com/vi/oikZlz1GNbo/default.jpg)
![The Youtube Algorithm Glitch (The Secret Youtube Exploit) - YOUTUBE IS A PERFECTLY BALANCED WEBSITE](https://i.ytimg.com/vi/Ej0Kijd4_4Q/default.jpg)