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
Match the academic requirements with the careers. Technical program , bachelors degree, doctorate degree can go with cosmetologi
Evgesh-ka [11]
Technical program - cosmetologist
Bachelors degree - nutritionist
Doctorate degree - molecular biologist
All careers are dependent on the required education for a particular career and the complexity of education to be competent.
8 0
3 years ago
Read 2 more answers
0111101101010110101110110001001011101001011101101010101010110101
rodikova [14]

Answer:

binary digits in computer system it belongs

4 0
3 years ago
How will I go about conducting the investigation on fake news
Leno4ka [110]

Answer:

You can begin your report, and write about CNN, BBC, or any other liberal news network.

Explanation:

5 0
2 years ago
Gina is upgrading your computer with a new processor. She installed the processor into your motherboard and adds the cooling sys
tigry1 [53]

Answer:

The answer is option d.

8 0
3 years ago
Read 2 more answers
You were discussing software piracy with a friend and were surprised to learn how software piracy can impact your life every day
Vika [28.1K]
Those who use pirate software:
<span>1)Increase the chances that the software will not function correctly or will fail completely
2)Forfeit access to customer support, upgrades, technical documentation, training, and bug fixes
3)Have no warranty to protect themselves
4)Increase their risk of exposure to a debilitating virus that can destroy valuable data
5)May find that the software is actually an outdated version, a beta (test) version, or a nonfunctioning copy
6)Are subject to significant fines for copyright infringement</span>
5 0
3 years ago
Other questions:
  • Describe mobile computing
    7·1 answer
  • Obtain a file name from the user, which will contain data pertaining to a 2D array Create a file for each of the following: aver
    5·1 answer
  • Why is it important to not get distracted while driving?
    13·2 answers
  • OSHA standards appear in the ___________ and are then broken down into ____________.
    9·1 answer
  • Cual es la definición de grouded?​
    7·1 answer
  • Linda subscribes to a cloud service. The service provider hosts the cloud infrastructure and delivers computing resources over t
    10·1 answer
  • Como se diseña y produce un material audiovisual
    5·1 answer
  • Define and explain the two different methods by which a file can be compressed. Briefly describe one pro and one con for both ty
    13·1 answer
  • Please help ASAP!
    5·1 answer
  • Create a Flowchart and write pseudocode for a program that allows the user to enter two integer values: a and b.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!