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

preview_player
Показать описание
Level Order Traversal of a Binary Tree (level by level and as a whole).
Explanation in detail for both representations of level order traversal.
Рекомендации по теме
Комментарии
Автор

Amazing great algorithms
!!!Thank you for posting this. Awesome video as always. Keep up the good work!!

xiangwingrace
Автор

Thank you sooo much man! No matter what anyone says you are awesome and the way you make things clear is amazing. Thanks again :)

programming_and_snacks
Автор

love the way you are explaining the things, best ds tutorials

juhimittal
Автор

Awesome Teaching Sir... You made algorithms subject easy to understand. I will be always grateful to you.

pramodsable
Автор

🔥🔥 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

ayushvats
Автор

thank you for step by step instructions. Makes a big difference in understanding until the end!

lresleland
Автор

Program using above algorithm:

public static void LevelOrderTrversal(TreeNode root)
{
Queue<TreeNode> q = new LinkedList<TreeNode>();
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++;
}
}
}

suchitrakunnath
Автор

hats off keep it up and upload videos in same manner!!
thanks a lot!!

kirandhedhi
Автор

Amazing explanation sir.
Really liked it👍👍🥳🥳

sejalrathore
Автор

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.

AvinashKumar-uzfq
Автор

Now I did understand the algorithm on wikipedia. Thank you.

xCwieCHRISx
Автор

great explaination ... i was struggling to understand this

abhisheksaxena
Автор

You are awesome brother. Better than G* i should say !

ryan-boxi
Автор

Thanks for the great explanation Vivekanand.

smn
Автор

do you provide live coaching for interview preparation. ?

ashishg
Автор

How can I store each level into an ArrayList? Not just printing them all sequential out.

tyler_ua
Автор

Very Nice and clear explanation sir :)

sandeepmunavalli
Автор

Thankx sir, So level order traversal and BFS is same ?

ArunKumar-wyqv
Автор

Clear and crisp explanation. But do it with code.

kkbh
Автор

Who is your guru? Great explaination...!

nitinsridhar