Binary Tree in Java - 15 : Print Right View of Binary Tree

preview_player
Показать описание

In this video, we're going to reveal exact steps to print right view of binary tree in Java

Please check video for more info:

CHECK OUT CODING SIMPLIFIED

★☆★ VIEW THE BLOG POST: ★☆★

I started my YouTube channel, Coding Simplified, during Dec of 2015.
Since then, I've published over 200+ videos.

★☆★ SUBSCRIBE TO ME ON YOUTUBE: ★☆★

★☆★ Send us mail at: ★☆★

This problem is similar to following:
print right view of binary tree in Java,
print right view of binary tree,
Binary Tree print right view,
binary tree,
java tutorial,
coding simplified,
java
Рекомендации по теме
Комментарии
Автор

the best video so far i found for tree

yashpreetbathla
Автор

amazing !!! simple !!! i thought complex solution, your solution is simple...fantastic !!!

selvalooks
Автор

sir you are traversing all nodes but i am thinking it is unnecessery instead o a small change where level=0 && maxlevel greater> level return

sai-cn
Автор

Nice 👍😊, I am learning data structure from ur channel, amazing content🤗

soniabharti
Автор

Amazing Content, just one doubt on the statement

if(level >= maxLevel) {
System.out.print(node.data + ” “);
maxLevel++;
}

what if we only check for (level==maxlevel) will that be sufficient ?

abhishekkumarsrivastava
Автор

Dude your videos are truly awesome!
However I am not getting an idea of how recursion works on a tree.
It's really confusing.
Do you have any video on how it works step by step?
If not, can you make one?

f-faithfitnessfinance
Автор

There is mistake in your function, it should be like

var maxLevel = 0
fun printTreeRightView(root: Node?, level: Int) {

root ?: return

if (maxLevel == level) {
print("${root.data} ")
maxLevel++
}

printTreeRightView(root.right, level + 1)
printTreeRightView(root.left, level + 1)

}

ManojKumar-kvpu
Автор

what we have to do if level is not given in input?? and we have to print output in list

surajgrandhi
Автор

this code doesnt wor for right view it works for level order

vibhasavr
join shbcf.ru