Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

Q. The two Binary Trees are said to be similar if they are both empty or if they are both non- empty and left and right sub trees are similar. Write down an algorithm to determine if two Binary Trees are similar.                                                                                                       

Ans:

We assume that the two trees are tree1 and tree2. an algorithm to determine if two Binary trees are similar or not is as follows:

similar(*tree1,*tree2)

{

while((tree1!=null) && (tree2!=null))

{

if((tree1->root) == (tree2->root)) similar(tree1->left,tree2->left); similar(tree1->right,tree2->right);

elseif(tree->root!=   tree2->node){printf("Trees

are not equal");

return;}

}

}

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M9504028

Have any Question?


Related Questions in Computer Engineering

What service is defined as it services for example in a gym

What service is defined as IT services? For example, in a gym, is members called IT services? What else? could you give me another example?

A cell phone company offers 15 different voice packages and

A cell phone company offers 15 different voice packages and 15 different data packages. Of those, 6 packages include both voice and data. How many ways are there to choose either voice or data, but not both?

What is the transmission type transmission form

What is the Transmission Type, Transmission Form, Transmission Speed, Address for Transmission and Collusion for hubs?

In a survey of 3236 adults 1470 say they have started

In a survey of 3236 adults, 1470 say they have started paying bills online in the last year. Construct a? 99% confidence interval for the population proportion. Interpret the results.

Question what are some risks of the project development

Question : What are some risks of the project development process you might encounter and what can you do to mitigate or avoid the problems? The response must be typed, single spaced, must be in times new roman font (siz ...

1 define organizational communication2 what interesting

1. Define organizational communication 2. What interesting about the subject of organizational communication

Sub classassume super class and methods defined in question

Sub Class Assume Super Class and methods defined in question VIII Assume a Sub class named RunSomeSuper Write the Begin method Construct an instance of SomeSuper with parms of your choosing Just the Begin method, not the ...

Restaurant management database project the restaurant

Restaurant Management Database Project : The restaurant maintains the catalog for the list of food and beverage items that it provides. Apart from providing food facility at their own premises, the restaurant takes order ...

This is in reference to cshort answer questions1 what is

This is in reference to C++ Short Answer Questions: 1) What is the definition of Big-O? What do we use Big-O notation to show? 2) Define recursion. Can every recursive algorithm be written as an iterative algorithm? 3) H ...

Please elaborate your understanding about how rfid and nfc

Please elaborate your understanding about how RFID and NFC work. What are the current security considerations and challenges?

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As