1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
svetlana [45]
3 years ago
14

Write a recursive function that calculates if two binary trees are similar?

Computers and Technology
1 answer:
ahrayia [7]3 years ago
5 0

Answer:

bool identicaltrees(Node* root1,Node* root2)//function of type boolean true if idenctical false if not.

{

   if(root1==NULL&&root2==NULL)//both trees are null means identical.

   return true;

   if(roo1 && root2)

   {

       if(root1->data==root2->data)//condition for recursive call..

       {

           return (identicaltrees(root1->left,root2->right)&&identicaltrees(root1->right&&root2->right);

       }

   }

   else

   return false;

}

Explanation:

In this function it of type boolean returns true if both the trees are identical return false if not.First we are checking root node of both the trees if both are null then they are identical returning true.

If both root nodes are not null then checking their data.If data is same then recursively traversing on both trees and checking both trees.

else returning false.

You might be interested in
TRUE OR FALSE!!!!!
VladimirAG [237]
The answer is True.
6 0
3 years ago
Read 2 more answers
How many words fit on a double-spaced page?
sveticcg [70]
It depends on the length of the words.
5 0
3 years ago
Why is a positive attitude towards work important
bezimeni [28]

Answer:

it lets you get more work done

Explanation:

when you have a positive work attitude you want to do more stuff, and when it's bad you won't want to do anything

3 0
2 years ago
PLEASEEEE PLEASEEE HELPPPP
olga nikolaevna [1]

Explanation:

you need a better pic if possible, it's kinda hard to read the question.

4 0
2 years ago
Which camera does Angelina use?
julia-pushkina [17]

Answer:

mirrorless cameras have lot more space due to not having mirrors. and they have the same or better quality than DSLR's.

8 0
3 years ago
Other questions:
  • Joaquin is considering a career as an animator and wants to know more about the daily work of an average animator. Which strateg
    11·1 answer
  • When inserting a fly in animation what is the first step in the process?
    9·1 answer
  • You were fortunate to get the ice off of the wings, but whatever caused the cabin to depressurize also vented all of your fuel o
    11·1 answer
  • In order to consolidate your theoretical knowledge into technique and skills with practical and applicational value, you will us
    8·1 answer
  • How many possible keys does the playfair cipher have? an approximate power of 2
    14·1 answer
  • What is the term used for describing the judgement or common sense part of problem solving​
    11·1 answer
  • The order of precedence is very important when building formulas in Excel. Which of the following formulas will produce 778 as t
    11·1 answer
  • How do you delete answers on Brain.ly?
    11·2 answers
  • How do I insert a row above the selected row in between row and row 2 revenue xls
    5·1 answer
  • Bank Account Postings While reviewing your checking account balance online, you notice that debit card purchases have not posted
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!