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
Consider the following classes:
aleksandrvk [35]

Answer:

The answer is toy

Explanation:

I think toy is the odd one out

4 0
3 years ago
In report design view, you can use commands on the align button of the _____ tab.​
gogolik [260]
I'd say the Arrange tab

Sizing and moving fields in design view can sometimes be time consuming. Be that as it may, we can always use the tab order dialog box to perform this operation. To do so, we select the labels and fields in question, proceed to the Arrange tab, sizing and ordering group and then click on the Align button.


5 0
3 years ago
Find every number from 1 to n (inclusive) that is a palindrome which starts with the digit 3. Do not user a helper function.
Mkey [24]

Answer: Following code is in python

n=input()

num='1'

while int(num)<=int(n):    //loop from 1 to n

   flag=1   //if an unequal element will be found it will be 0

   l=len(num)

   if num[0]=='3':

       j=0

       k=l-1

       while j<k:    //loop till middle of number

           if num[j]==num[k]:

               j+=1     //from beginning

               k-=1    //from end

           else:

               flag=0

               break

       if flag==1:

           print(int(num))

   num=str(int(num)+1)    //number will be incremented as integer

INPUT :

1000

OUTPUT :

3

33

303

313

323

333

343

353

363

373

383

393

Explanation:

In the above code, a loop is executed till num is equal to n which is entered by the user. num is treated as a string so that to ease the process of checking first character is 3 or not. If it is 3 then another loop executes which checks if an element from starting is equal to the corresponding element from the end. If an element is not equal then the flag is changed and then we break out of the loop and prints the number if the flag isn't changed.

7 0
3 years ago
Portable Document Format (PDF) is a file format that provides an electronic image of a document and can be viewed, printed, and
bogdanovich [222]
True a pdf is a file format that provides a electronic image of a document and it can be viewed, printed and electronically transmitted.
7 0
3 years ago
Read 2 more answers
Estoy empezando a usar una pagina llamada source filmmaker, no se que apreté y quiero el menú de nuevo (en donde se ponen los mo
yuradex [85]

Answer:

hay un n t s en la esquina superior derecha, debe presionar eso y debe llevarlo al menú si eso no funciona, entonces tengo una idea de qué hacer

Explanation:

7 0
3 years ago
Other questions:
  • Nathan wants to create multiple worksheet containing common formatting styles for his team members. Which file extension helps h
    5·1 answer
  • What does the picture indicate on the famous book “Dawn of the century”?​
    10·1 answer
  • What considerations have to be kept in mind with JPEG
    10·1 answer
  • python If the checksum is 10, the last digit is denoted as X according to the ISBN-10 convention. Write a program that prompts t
    10·1 answer
  • How would you display all your photographic work in your résumé, if you have a large volume of work?
    10·1 answer
  • Field names should NOT start with a(n) -<br> hyphen (-)<br> Oa<br> asterisk (*)<br> space()
    8·1 answer
  • Instructions:Select the correct answer from each drop-down menu. What type of font color should Kim select if she chooses a dark
    10·2 answers
  • Which hexadecimal number is equivalent to the decimal number 11?
    13·1 answer
  • A user is trying to delete a file located on an ntfs volume on his windows 8 computer but is unable to do so. Why is this.
    5·1 answer
  • A TCP Sender is just about to send a segment of size 100 bytes with sequence number 1234 and ack number 436 in the TCP header. W
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!