Check if two binary trees are identical (Algorithm/code/program)

preview_player
Показать описание
Given two binary trees, write a program to check whether they are identical.
Рекомендации по теме
Комментарии
Автор

Oh my word you are very good at explaining things. Nice teaching style, very clear.

marcelagomez
Автор

You are really crisp at your knowledge Thank you so much sir!!!

deepak-lvvn
Автор

Just to add how check function can be applied under boolean condition since, check function is returning int. Either check need to return boolean then it will work perfectly fine.

amreshkumar
Автор

Alternative method :-
bool check ( node* p1, node *p2 )
{
if( p1 ==NULL && p2 ==NULL )
return true;

if( p1 !=NULL && p2 !=NULL )
return ( check ( p1 -> left, p2 -> left ) && check ( p1 -> right, p2 -> right ) );
return false ;
}

harshvijeta
Автор

amazing! keep this simple and understandable explanation

FELIPESILVA-ppmr
Автор

sir ..u r doing gr8 job job on making videos on ds n keep more videos on ds n

milimishra
Автор

Good explanation, but if you specify the time and space complexity for every problem it will be more helpful

karthikeyanselvarajan
Автор

thank you for uploading video on algorithm, great job sir, nice explanation, keep adding more video.

travelogue
Автор

perfect! The way I was writing it took way longer.

ZirJohn
Автор

Thank you, your videos are very helpful for me!

kingdavey
Автор

I am thinking another way that, we can do by using level order traversal for the both the tree and in the end check both the string equal or not. if it equal the tree is identical.

amreshkumar
Автор

how to write algorithm for adding of two tree and to form one bst ??

thinkdifferent
Автор

Hi Vivekanand. Thank you for your video. I have one question about the true case. Can there also be a true case when the subtree has no more nodes (so p2 == null) but the main tree still has nodes remaining (p1 != null). In this case the subtree has already been found without traversing all the way down to tree 1's leaf nodes. Thank you.

anishasrivastava
Автор

Sir what is the time complexity of this algorithm

arghyamitra
Автор

good pls try to inlcude time and space complexity in the algo.!

prnk
Автор

Bro Your sequence of videos in this playlist is a mess.. please check and correct it.

SahilSharma-zznv
Автор

sir.. I kindly request you to make videos on arrays, matrices and strings wic r important and upload it soon..can u do it at the earliest??

saranyasaravanan
Автор

come on man u are a programmer at least drop your link in description

supamdeepbains
Автор

U have not mentioned the other 2 cases when:
1) p1==NULL && p2!=NULL return 0;
2)p1!=NULL && p2==NULL return 0;

nityanand_patna