Vertical Order Traversal of Binary Tree | Vertical Traversal of a Binary Tree | DSA-One Course #72
Hey guys, In this video, We're going to solve an important problem known as
'Print the Vertical Traversal order of a Binary Tree'
Practice the problem here: practice.geeksforgeeks.org/pr...
💸 Use coupon code ANUJBHAIYA on GeeksforGeeks to avail discounts on courses!
🥳 Join our Telegram Community:
Telegram channel: telegram.me/realanujbhaiya
Telegram group: telegram.me/dsa_one
🚀 Follow me on:
Instagram: / anuj.kumar.sharma
Linkedin: / sharma-kumar-anuj
Twitter: / realanujbhaiya
📚 Complete DSA Playlist: • DSA-One Course - The C...
Complete Android Development Playlist: • Android Development Tu...
Hashtags:
#anujbhaiya #dsaone
Tags:
vertical order traversal of binary tree
vertical traversal of binary tree
vertical order traversal
vertical order traversal of a binary tree
binary tree vertical order traversal
vertical traversal
top view of binary tree
binary tree
vertical order traversal of binary tree java
boundary traversal of binary tree
diagonal traversal of binary tree
dsa
level order traversal
tree traversal
level order traversal binary tree
tree dsa
314. binary tree vertical order traversal
987. vertical order traversal of a binary tree
anuj bhaiya java
binary tree traversal
bottom view of binary tree
dsa one
in order traversal
left view of binary tree
merge sort
tree
tree traversal in data structure
all nodes distance k in binary tree
apna college
bfs algoritması
binary trees
crop yield prediction based on indian agriculture using machine learning
diagonal traversal
dsa tree
flattening a linked list
invert binary tree
java anuj bhaiya
java by anuj bhaiya
java multithreading tutorial
love babbar dsa sheet
vertical order
vertical paths
zigzag traversal
Пікірлер: 45
*The leetcode and GFG version of this problem is different.*
@rushidesai2836
29 күн бұрын
Yes. Leetcode version is more difficult to visualize than this. But it's doable.
This question is almost simlar to the Top View of Binary Tree, only difference is there we are storing first Node we get from the tree in mapValue, and here we are storing ArrayList in MapValu. and As always Great Explaination Bhaiya👌
Present sir.... Abhi tk sab samajh me aa rha h 👍 thank you
Only first person on yt that take me a great explanation on an vertical level traversals
@priyanshudwivedi3454
Ай бұрын
It means that you haven't explored KZread completely yet
Thank you you're single handedly saving us all 🥺🥺
Best explanation on Vertical Traversal order of a Binary Tree
great work bhiya , concepts clear hogye 👍🥂
Thankyou soo much for best explanation on this traversal in java
Thank you anuj bhaiya for this good explanation.
Great way to teach tbh, that dry run was super helpful.
Thank you bhaiya, totally understood
love you anuj bhaiya,you are doing very great job for us thank you so much❤️❤️👑😊😊😊🚀👍
Anuj bhaiya tq for providing quality content ......bhaiya DP ka v dhyan rakheyega
Thank you bhaiya, your DSA one is the most comprised and best resource for preparing for placements 😍🤗
Anuj Bhaiya is really Jeetu bhaiya
Good work bhai
Great Bhaiya
great explanation
bhaiya this question is similar to bottom view of binary tree we just need to do small change i.e map mp;
@aashishjadhav4415
Жыл бұрын
actually this concept is used to solve bottom view
Bhaiya please can you upload full course asap please !!!
Bhaiya dp , graph , and advanced data structures aayega na
Bhayya i do want this code in cpp
Bhaiya ek optimal binary search tree pe video banao. Samjh nhi aa rha baki videos me
there is catch if same element in level and horizontal distances the insertion should be in sorted order which makes question more annoying.
I really like your videos but this problem can be solved through normal tree traversal (recusion) eg inorder traversal. if we take care of both vertical distance (left-> -1 , right-> +1) as well as horizontal distance (level) I agree it might be easy with level order traversal, but recursion totally doable & clean PS - learnt recusion (in general) from you only :)
@divyanshdimri8567
Жыл бұрын
no i dont think so coz inorder goes on the extreme left let say we have 3 nodes on the left from root so last node on the left will be -3 and after the last node it will go to the right so with ur concept u will do +1 which will be -2 but it shud be -1 . try it urself :)
plz anyone share code link
why we write "new" keyword inside q.add(new pair()) ?
@aashishjadhav4415
Жыл бұрын
bcz every time we are making new object of Pair class
Thank sir your videos are helping me alot ........ But i have one problem can you explain it once how to take matrix input in java for placement coding round because they are given in comma separated for just like 1,2,3 2,3,4..
@kiku_to_herself
2 жыл бұрын
I think u should consider buffered reader for this Read about it , and there are ways to take such input. I faced the same problem in infytq , and I used buffered reader there And mostly in java , when u will see , input is taken using buffered reader So consider , studying about it
Bhaiya me tier 3 college se hu... Mera placement tier 1 company me ho jaye to mera interview le lena 😁😛
In Js getting out of heap class Solution { //Function to find the vertical order traversal of Binary Tree. verticalOrder(root) { let ans = {}; function helper(root, vh) { if (!root) { return; } if (ans[vh] != undefined) { ans[vh] = [...ans[vh], root.data]; } else { ans[vh] = [root.data] } helper(root.left, vh-1) helper(root.right, vh+1) } helper(root, 0); return Object.keys(ans).sort((a, b)=>a-b).map((ele)=> [...ans[ele]]).flat() } }
First
111
Bhaiya Graph Shuru kra do.
treemap banane ke baad to wo nlogn TC hogaya
Your Tree on Board is itself wrong.. please check i.e. 60 should be less than root node
@devanshprakash8354
Жыл бұрын
Abe bewakoof yeh binary tree h not bst
this code is not working in leetcode
@ashishkumarshawhitchem2017
Жыл бұрын
but working in gfg
@undextered
Жыл бұрын
@@ashishkumarshawhitchem2017 because leetcode wants elements in the same column sorted by their values