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
Nataliya [291]
4 years ago
8

As usual, create a public class called YourBinaryTree that extends BinaryTree, override public boolean equals(Object other), and

implement it as described above. If other is null or not a BinaryTree you should return false. As a reminder you can access protected BinaryTree instance variables in equals, including on other, which you will need to do to start the recursion on other.
Computers and Technology
1 answer:
kobusy [5.1K]4 years ago
8 0

Answer:

// YourBinaryTree class implementation

public class YourBinaryTree extends BinaryTree

{

// equals method implementation

Override

public boolean equals(Object other)

{

// if other is null or not a BinaryTree, then return false

if (other == null || !(other instanceof BinaryTree))

{

return false;

}

// if both classes are not same, then return false

if(getClass() != other.getClass())

return false;

// caste other object to YourBinaryTree

YourBinaryTree otherBinaryTree = (YourBinaryTree) other;

// call the equals recursive helper method

return equals(root, otherBinaryTree.root);

} // end of equals method

// equals recursive helper method implementation

private boolean equals(Node root1, Node root2)

{

// return true if the current nodes of both trees are null

if(root1 == null && root2 == null)

{

return true;

}

// return false if one current node is null and another current node is not null

if((root1 != null && root2 == null) || (root1 == null && root2 != null))

{

return false;

}

// return false if the values at the current nods of both trees are not equal

if(!(root1.value.equals(root2.value)))

return false;

else

// recursive calls to the equals recursive helper method for left and right subtrees

return (equals(root1.left, root2.left) && equals(root1.right, root2.right));

} // end of equals recursive helper method

} // end of YourBinaryTree class

Explanation:

This works only if you cast BinaryTree instead of YourBinaryTree in the first public boolean equals(Object other)

The program takes in or accepts public class called YourBinaryTree that extends BinaryTree, override public boolean equals(Object other), and implement it as described above. If other is null or not a BinaryTree you should return false.

You might be interested in
Which presenter would most likely benefit from a custom slide show?
Gelneren [198K]
I would say a salesman or woman would most benefit from a custom slide show that shows a product, explains what it is, where it comes from, how it is made and especially how it can be used to benefit an organization as these things or qualities should be fairly cut and dried and well worked out unlike say a technique that depends on the circumstances like installing a piezometer (an instrument to read water pressure) in a drill hole in which case a particular slide show rather than a custom one would have to be used.
7 0
3 years ago
Which statement about tuition is the most accurate?
Kisachek [45]

public colleges are cheaper for in-state residents

5 0
4 years ago
Read 2 more answers
The number of colors in a bitmap image determines which category the image will be in. Complete the following sentences.
Jobisdone [24]

Answer:

Explanation:

1.Grayscale

2.Multitone

7 0
4 years ago
Maria is starting a pet hotel and needs a website to promote her business and establish her brand. Which of the following is the
german

<em>The answer is </em><em>C. Maria should use turnkey solution that will allow her to use templates and management tools to create a site. </em>

<em> </em>

<em>Turnkey solution</em><em> is a type of business solution that can allow business owners to use these ready-made tools, templates and system to their existing process and business operations. Such tools include </em><em>CRM </em><em>and websites. For example, you are in need of a Loans Management System, that must be implemented next week. You can browse for Loans CRM that are widely available on the internet, subscribe to the service, make payment and this could be used right away in your business operation. Same thing with Maria's needs on the website. She could just subscribe to a website that can allow her to create pages and links with drag and drop and make it running right away.</em>

8 0
3 years ago
Utilitarianism does not mean "the greatest good of the greatest number" because a) it is impossible to calculate "the greatest g
pantera1 [17]

Answer:

The correct option is B: It focuses solely on "the greatest good" and pays no attention to how "the good" is distributed.

Explanation:

The theory of Utilitarianism promotes actions that enhances pleasure and the greatest good and opposes actions that can result to harm or unhappiness. However, this theory does not imply the greatest good for the greatest number of people and has been criticized for it. Critics state that Utilitarianism only focuses on the greatest good, but it shows no concern for the distribution of the good.

8 0
4 years ago
Read 2 more answers
Other questions:
  • If the object instance is created in a user program, then the object instance can access both the public and private members of
    9·1 answer
  • Longer speeches should be separated into the paragraphs of:
    9·1 answer
  • Assume you have a sorting algorithm that you can use as a black box. Use the sorting algorithm to sort the input list. Now write
    10·1 answer
  • The _____ layer of the Open Systems Interconnection (OSI) model generates a receiver’s address andensures the integrity of messa
    6·1 answer
  • A help desk manager needs to know the
    15·1 answer
  • To make sound decisions about information security, management must be informed about the various threats facing the organizatio
    10·1 answer
  • You want to centrally back up the files users store in the Documents folder in their user profiles, but you don’t want users to
    7·1 answer
  • Consider the following code: public static void mystery(int a) { System.out.println("A"); } public static void mystery(double a)
    6·1 answer
  • In the U.S. fuel efficiency of cars is specified in miles per gallon (mpg). In Europe it is often expressed in liters per 100 km
    12·1 answer
  • Will creates an entry in his calendar and marks it as an all-day instance. Which item has he created?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!