Level Order Traversal of a Binary Tree (level by level and as a whole)

  Рет қаралды 51,135

Vivekanand Khyade - Algorithm Every Day

Vivekanand Khyade - Algorithm Every Day

Күн бұрын

Пікірлер: 91
@xiangwingrace8672
@xiangwingrace8672 6 жыл бұрын
Amazing great algorithms !!!Thank you for posting this. Awesome video as always. Keep up the good work!!
@ayushvats1808
@ayushvats1808 3 жыл бұрын
🔥🔥 the best part is u actually explained so calmly like one by one. and explained how the output is actually coming with that algorithm for all cases if anything will be explained like this.. concepts gonna so easy
@pramodsable4482
@pramodsable4482 5 жыл бұрын
Awesome Teaching Sir... You made algorithms subject easy to understand. I will be always grateful to you.
@columbiars
@columbiars 7 жыл бұрын
Excellent explanation Vivekanand!
@juhimittal3320
@juhimittal3320 2 жыл бұрын
love the way you are explaining the things, best ds tutorials
@lresleland4238
@lresleland4238 5 жыл бұрын
thank you for step by step instructions. Makes a big difference in understanding until the end!
@sejalrathore7080
@sejalrathore7080 3 жыл бұрын
Amazing explanation sir. Really liked it👍👍🥳🥳
@programming_and_snacks5192
@programming_and_snacks5192 5 жыл бұрын
Thank you sooo much man! No matter what anyone says you are awesome and the way you make things clear is amazing. Thanks again :)
@suchitrakunnath232
@suchitrakunnath232 6 жыл бұрын
Program using above algorithm: public static void LevelOrderTrversal(TreeNode root) { Queue q = new LinkedList(); q.add(root); q.add(null); int level = 1; while(!q.isEmpty()) { TreeNode temp = q.remove(); if(temp != null) { System.out.println("Level = " + level + " value = " +temp.val); if(temp.left != null) q.add(temp.left); if(temp.right != null) q.add(temp.right); } else { if(q.peek() == null) break; q.add(null); level++; } } }
@kirandhedhi2612
@kirandhedhi2612 7 жыл бұрын
hats off keep it up and upload videos in same manner!! thanks a lot!!
@kirandhedhi2612
@kirandhedhi2612 7 жыл бұрын
sir where is the code?
@Ankit-hs9nb
@Ankit-hs9nb 6 жыл бұрын
github.com/mission-peace/interview/blob/master/src/com/interview/tree/LevelOrderTraversal.java#L19
@m4riders
@m4riders 2 жыл бұрын
Very well explained sir
@smn656
@smn656 6 жыл бұрын
Thanks for the great explanation Vivekanand.
@dimpleshah3037
@dimpleshah3037 4 жыл бұрын
Superb explanation
@kasyapdharanikota8570
@kasyapdharanikota8570 3 жыл бұрын
very well explained. Thank you sir .
@AvinashKumar-uz9fq
@AvinashKumar-uz9fq 5 жыл бұрын
what will be the looping condition in line by line? If it's loop till queue is not empty then in the if condition p ==null, n the enqueue statement under it will make an infinite loop.
@coderix1404
@coderix1404 3 жыл бұрын
Awesome explanation
@vikashkumarchaurasia1299
@vikashkumarchaurasia1299 6 жыл бұрын
Outstanding explanation
@sweekriteesingh518
@sweekriteesingh518 4 жыл бұрын
Very nicely explained 👍
@himansuranjanmallick16
@himansuranjanmallick16 4 жыл бұрын
Awsome logic bro👌
@VirendraSingh-hd9yr
@VirendraSingh-hd9yr 3 жыл бұрын
thankyou sir for awesome explation
@omrajpurkar
@omrajpurkar 4 жыл бұрын
Nice Explanation!! Thank you 🙏
@ashishg656
@ashishg656 6 жыл бұрын
do you provide live coaching for interview preparation. ?
@ArunKumar-wy8qv
@ArunKumar-wy8qv 4 жыл бұрын
Thankx sir, So level order traversal and BFS is same ?
@malkitsaggu
@malkitsaggu 4 жыл бұрын
Great explanation.
@xCwieCHRISx
@xCwieCHRISx 4 жыл бұрын
Now I did understand the algorithm on wikipedia. Thank you.
@abhisheksaxena6413
@abhisheksaxena6413 2 жыл бұрын
great explaination ... i was struggling to understand this
@vivekanandkhyade
@vivekanandkhyade 2 жыл бұрын
Glad to help you.
@nitinsridhar7555
@nitinsridhar7555 4 жыл бұрын
Who is your guru? Great explaination...!
@ryan-bo2xi
@ryan-bo2xi 5 жыл бұрын
You are awesome brother. Better than G* i should say !
@vivektyson
@vivektyson 4 жыл бұрын
Awesome Sir
@sandeepmunavalli6345
@sandeepmunavalli6345 7 жыл бұрын
Very Nice and clear explanation sir :)
@prasannachalgeri7152
@prasannachalgeri7152 6 жыл бұрын
Awesome Videos!! I still think there are many missing like finding max element in binary tree using recursion and without recursion which indeed uses LOT. Can you also try to make videos on those topics
@kkbh4263
@kkbh4263 5 жыл бұрын
Clear and crisp explanation. But do it with code.
@dan-nm2tg
@dan-nm2tg 6 жыл бұрын
very clear to understand .thanks
@sachinsingh-jg9lx
@sachinsingh-jg9lx 4 жыл бұрын
Hats Off Buddy....
@tyler_ua6593
@tyler_ua6593 6 жыл бұрын
How can I store each level into an ArrayList? Not just printing them all sequential out.
@tyler_ua6593
@tyler_ua6593 6 жыл бұрын
For everybody who is seeking for the same answer. Here is the link:bit.ly/2HmIOm8
@paligamy93
@paligamy93 6 жыл бұрын
What's your return type look like?
@biplabsarkar4827
@biplabsarkar4827 7 жыл бұрын
great explanation sir
@ashishg656
@ashishg656 6 жыл бұрын
great video sir, thanks a lot
@preetamvarun9219
@preetamvarun9219 4 жыл бұрын
Man you're awesome seriously
@shanikumar2019
@shanikumar2019 6 жыл бұрын
You are awesome,Dear
@tapanjeetroy8266
@tapanjeetroy8266 5 жыл бұрын
Thank you sir
@Vishal-ng2xb
@Vishal-ng2xb 7 жыл бұрын
Hi ..very good explanation..but for left and right view how do I determine the node?for left view maybe the 1st node after each null..but for right view?
@milimishra6447
@milimishra6447 7 жыл бұрын
for right view it will be the end node at each level...
@RANJANJHA95
@RANJANJHA95 6 жыл бұрын
Using level by level (not in one line) For the left view: the first root node and then each node just after null. For left view: Any node just before null
@sudamkalpage8107
@sudamkalpage8107 4 жыл бұрын
thank you!
@amd7407
@amd7407 5 жыл бұрын
Thanks a lot for the video
@HebaHabashkpoper
@HebaHabashkpoper 4 жыл бұрын
thank you so much
@srilekha9177
@srilekha9177 6 жыл бұрын
Excellent explanation. Mention the codes also. It would be useful.
@arun26cs
@arun26cs 5 жыл бұрын
thank you much vivek!!!!
@HouseJunkieHUN
@HouseJunkieHUN 5 жыл бұрын
Thank you, Sir!
@keyurshah5203
@keyurshah5203 4 жыл бұрын
its really good
@taranjitsingh1115
@taranjitsingh1115 6 жыл бұрын
great work, man! cheers!
@surajne2419
@surajne2419 4 жыл бұрын
Good job Bro. Keep it up :)
@himanshusattavan1335
@himanshusattavan1335 5 жыл бұрын
wonderful
@prakashraj2411
@prakashraj2411 4 жыл бұрын
osm. explanation
@jingli2168
@jingli2168 5 жыл бұрын
Hope this help, but there is another simple version. # None version def horizon_level(root): if root is None: return queue = [] queue.append(root) queue.append(None) while len(queue) != 1: p = queue.pop(0) if p is not None: print(p.data) if p.left is not None: queue.append(p.left) if p.right is not None: queue.append(p.right) else: queue.append(None) return
@user-uh4be8ci7i
@user-uh4be8ci7i 2 жыл бұрын
thx
@NaRuCHi-ch
@NaRuCHi-ch 5 жыл бұрын
thank you so much !!!!
@Developer.786
@Developer.786 3 жыл бұрын
thank u
@moayyadarz2965
@moayyadarz2965 4 жыл бұрын
really it is amazing and outstanding explanation If we want to communicate with you how can we do that ? we ,a group of students from turkey ,want to take a paid course online from you hopefully you could help us all the best
@DeepakPandey
@DeepakPandey 7 жыл бұрын
Hi @vivekanand thanks for explanatory videos. Could you please cover trie data structures and there applications. Thanks in advance !
@Vishal-ng2xb
@Vishal-ng2xb 7 жыл бұрын
How do I check for consecutive null
@sunitshrivastava4448
@sunitshrivastava4448 7 жыл бұрын
inside if loop, check for next element of queue to be null and break out of while loop.
@jingli2168
@jingli2168 5 жыл бұрын
check the length of the queue if len == 1 then stop the while loop, cause only None in the queue
@tanzeemahmed9774
@tanzeemahmed9774 7 жыл бұрын
Great video. Do you have code sample?
@Ankit-hs9nb
@Ankit-hs9nb 6 жыл бұрын
github.com/mission-peace/interview/blob/master/src/com/interview/tree/LevelOrderTraversal.java#L19
@Bakepichai
@Bakepichai 7 жыл бұрын
superb.... :)
@i_amsinha
@i_amsinha 4 жыл бұрын
If the tree node has value of type "int" , the Null solution for line by line traversal isn't gonna work.
@talal194
@talal194 3 жыл бұрын
You can enqueue -1 then
@ramakrishnakcr4417
@ramakrishnakcr4417 3 жыл бұрын
❤️
@anandkulkarni2111
@anandkulkarni2111 6 жыл бұрын
There is much better and simple way to print level by level using recursive call collect items into map and then iterate level by level to print them
@HumbleMan78
@HumbleMan78 5 жыл бұрын
In case recursive function call is expensive , this method is suitable. The extra Queue memory is actually O(n) which is very less
@tusharsingh6792
@tusharsingh6792 3 жыл бұрын
will u please implement the same in code
@DentrifixoRam88
@DentrifixoRam88 7 жыл бұрын
great job!
@noureenislam7691
@noureenislam7691 6 жыл бұрын
where do i find the code?
@raj-nq8ke
@raj-nq8ke 3 жыл бұрын
(Dequeue Print Enqueue ) untill queue is empty.
@milimishra6447
@milimishra6447 7 жыл бұрын
nice..
@paraskumar693
@paraskumar693 3 жыл бұрын
This is vey High Lebel thinking
@VISHALSHARMA-mu9kl
@VISHALSHARMA-mu9kl 3 жыл бұрын
sir plzz also provide code for this
@ArpitDhamija
@ArpitDhamija 4 жыл бұрын
Iska code.....
@brahmam9842
@brahmam9842 5 жыл бұрын
Everything is Good.Improve English Bro.(Just suggestion)
@arvindkumarsharma5536
@arvindkumarsharma5536 5 жыл бұрын
What's wrong about his English?
@sachinsingh-jg9lx
@sachinsingh-jg9lx 4 жыл бұрын
Explained logic is crystal clear.....He wouldn't be working for BPO.
@jaysahu357
@jaysahu357 7 жыл бұрын
thank you sir
@vivekanandkhyade
@vivekanandkhyade 7 жыл бұрын
Welcome Jayram,
Print diagonal elements in binary tree(code/Algorithm/Program)
25:19
Vivekanand Khyade - Algorithm Every Day
Рет қаралды 20 М.
Vertical Order Traversal of a Binary tree (Algorithm)
18:35
Vivekanand Khyade - Algorithm Every Day
Рет қаралды 71 М.
龟兔赛跑:好可爱的小乌龟#short #angel #clown
01:00
Super Beauty team
Рет қаралды 68 МЛН
Seja Gentil com os Pequenos Animais 😿
00:20
Los Wagners
Рет қаралды 43 МЛН
Spiral (zig-zag) level order traversal of a binary tree
14:12
Vivekanand Khyade - Algorithm Every Day
Рет қаралды 34 М.
2.6.1 Binary Search Iterative Method
19:36
Abdul Bari
Рет қаралды 820 М.
Bottom view of a Binary Tree Algorithm
12:28
Vivekanand Khyade - Algorithm Every Day
Рет қаралды 36 М.
Height of a Binary Tree / Maximum depth of a binary tree Algorithm [REVISITED]
16:50
Vivekanand Khyade - Algorithm Every Day
Рет қаралды 119 М.
Binary tree traversal - breadth-first and depth-first strategies
11:54
A* Search
12:32
John Levine
Рет қаралды 419 М.
Level Order Traversal | Tree | HackerRank | Python
12:24
Coding Cart
Рет қаралды 9 М.
Binary tree traversal: Preorder, Inorder, Postorder
14:29
mycodeschool
Рет қаралды 960 М.
龟兔赛跑:好可爱的小乌龟#short #angel #clown
01:00
Super Beauty team
Рет қаралды 68 МЛН