Top view of Binary Tree | Bottom view of Binary Tree | Binary Tree Data Structures Java | DSAOne #61

preview_player
Показать описание
Hey guys, In this video, We're going to learn how to print the Top View and the Bottom View of a Binary Tree.

Practice here:

💸 Use coupon code ANUJBHAIYA on GeeksforGeeks to avail discounts on courses!

🥳 Join our Telegram Community:

🚀 Follow me on:

Hashtags:
#anujbhaiya #dsaone

Tags:

top view of binary tree
bottom view of binary tree
top view of a binary tree
top view
top view binary tree
top view of tree
binary tree in data structure
top view of a tree
binary tree
anuj bhaiya java
left view of binary tree
bottom view of a binary tree
tree in dsa
dsa
tree data structure in java
java anuj bhaiya
java by anuj bhaiya
right view of binary tree
anuj bhai
trees dsa
anuj kumar sharma
binary search tree
binary tree playlists
binary trees
diameter of binary tree
dsp anuj bhaiya
tree dsa
tree traversal in data structure
trees in data structure
vertical order traversal of binary tree
what is binary tree
binary tree data structure
binary tree in java
binary tree playlist
complete binary tree
ishan sharma
love babbar
tree data structure
trees data structure
trees data structures
width of binary tree
aditya verma
akshay saini
arraylist
babbar code help
balanced binary tree
binary search tree in data structure
binary search tree in java
binary search tree java
binary tree c++
binary tree java
binary tree tutorial
bottom view
boundary traversal of binary tree
code help babbar
data structure
diameter of a binary tree
diameter of a tree
diameter of tree
dsa one
dsa sheet
harman singh
invert binary tree
kunal kushwaha
largest bst in bt
longest common subsequence problem
node js
print nodes in top view of binary tree
right side view of a binary tree
seed it solution
top
tree in java
tree topology
treemap
treemap in java
trees in dsa
Рекомендации по теме
Комментарии
Автор

Now I can say my Nonlinear Data structure journey has been started with Anuj Bhaiya 🙏🙏🙏🙏🙏 Thank You Sir ❣❣❣❣.

subhankarpal
Автор

Nice solution.
But i found out a little bit optimization for the above solution.
Consider d= horizontal diameter of the tree.
Building Treemap takes o(dlogd).
Instead of TreeMap use HashMap and maintain two static variables i.e., min and max and update the min and max values as
min=Math.min(min, temp.hd);
max=Math.max(max, temp.hd);
for every iteration.
Now traverse the HM from min to max and add those values to a new ArrayList.
This will reduce the time complexity from O(n+dlogd) to O(n)

raghunath
Автор

Never knew that this medium level topic is going to be so easy for me
Thank yoy

abdullahirfan
Автор

You are Such as Good Mentor 🥰 i really inspired your video when did I watch ❤

Jitendrachouhan
Автор

Very Clean and Neat Explaination, Sir!

udaychandu
Автор

You are genious dude…!!! Applauses 👌👌👌

RepublicDay
Автор

awesome bhaiya, thanks for making coding easier

ANJALIGUPTA-vqcv
Автор

for implementing the queue method we can define three variables in class third one to store level and in the if condition we will check using or operator that if the level of incoming node is lesser than the already existing node it will replace the node. Please tell me if something is wrong with this approach . Open to other suggestions.

hangover.
Автор

, vertical order, top view, bottom view, what an explanation ☺☺☺

prashantkumarsingh-uiyp
Автор

Thank you bhaiya, best explanation ever.

MindsetMotivation
Автор

Can you please provide a 60roamdap of important topics for DSA beginner to crack tech giant's like Microsoft linkedin etc

tech_wizard
Автор

Thank you so much bhaiya mai yhi same glti kar rha tha.... thank you

harshvardhansingh
Автор

Few days ago, bhaiya you suggested a youtube channel for learning java from scratch (u told, u also learnt from there) please give that channel link again, I forget that channel name. 🙏🏻

abhishekanuj
Автор

Not sure if it is the correct logic for bottom view.
Consider this example.
7(0)
/ \
6 (-1) 2 (1)
/ \ / \
5 ( -2 ) 1(0) 8(0) 2 (2)

We have 2 0s at bottom, but the map would hold just 1 zero. So your logic would give -> 5, 8, 2 instead of 5, 1, 8, 2.

Or am I missing something?

ImranKhan-mcvf
Автор

what is the time complexity of this solution

sumitchakraborty
Автор

can somebody tell me why are we using level order only?

mohakarora
Автор

Bhaiyaa DevOps par ek video banaiye isme career kaise banaye

shivamchaurasiya
Автор

did u have a computer science degree??

wizardiors
Автор

Sir background video recorder app se user Jo video record karta hai kya vo video app Wale ke pass bhi store hota hai kya
Kya ye possible hai ki Jo video hum record karte hain vo app Wale ke pass bhi store hota hai kya

harishlodha
Автор

why we don't take preorder traversal for bottom view, kindly give a tree example where preorder traversal gives wrong answer.

shaileshtiwari