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
Is an electronic scavenger hunt played around the world.
pogonyaev
It can be played around the world
4 0
4 years ago
Question #8
White raven [17]

Answer:

The other person is correct the answer is 7

Explanation:

I got it right on edge

3 0
3 years ago
Why does a layer 3 device perform the anding process on a destination ip address and subnet mask?
mafiozo [28]
To get the network number and node number of the destination machine. The subnet mask is usually called the NETwork MASK, so anding it with the address gives you the network number. Using the not logical operator on the netmask then protects the node bits in a second and operation.

address & netmask = network number
address & not( netmask ) = node number

The not operator essentially just flips the bits of it's argument.
8 0
3 years ago
Write measure five safety measures can be taken to stay safe in social media​
alexdok [17]

Answer:

  1. <u>Use a strong password</u>.
  2. <u>Use a different password for each of your social media accounts</u>.
  3. <u>Set up your security answers. </u>
  4. <u>If you have social media apps on your phone, be sure to password protect your device.</u>
  5. <u>Be selective with friend requests. </u>

5 0
3 years ago
Read 2 more answers
Is 1/5 a rational number, interger, whole number, and natural
gayaneshka [121]

Answer:

1/5 is a rational number.

Explanation:

Natural numbers are the numbers you use to count with (1, 2, 3, etc.). Nobody uses fractions while counting whole objects unless they think they're funny and want to stall, so 1/5 wouldn't be a rational number.

Whole numbers are the exact same as natural numbers, but with the addition of the number 0 (think about it, no one starts from zero when counting).

Integers include whole numbers as well as their opposites (for example, the opposite of 4 is –4).

As a basic rule of thumb, if the number includes a fraction or a decimal point of any kind, it would be a rational number.

4 0
3 years ago
Other questions:
  • The condition, ____, entered in the criteria row of a long text field in a query window would retrieve all records where the lon
    8·1 answer
  • What might happen if a computer has too many applications running at one time?
    15·1 answer
  • You work at a computer repair store. You just upgraded the processor (CPU) in a customer's computer. The computer starts, but it
    11·2 answers
  • ​a(n) ____ is a communications device that connects a communications channel such as the internet to a device such as a computer
    11·1 answer
  • Specification of database requirements falls under which category of database​ administration?
    8·1 answer
  • How to write an shortened if statement?
    6·1 answer
  • A date consists of a month, day, and year. Consider the class Date of such dates. Suppose that Date represents the month, day, a
    14·1 answer
  • write a program in C# that reads a set of integers and then finds and prints the sum of the even and odd integers?​
    12·1 answer
  • 1. Which of the following cables are used in networking? Check all that apply.
    8·2 answers
  • What is the most used gaming keyboard in 2022?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!