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
NNADVOKAT [17]
3 years ago
10

Write a method equals that could be added to the IntTree class. (On your handout this method is called "equals", but Practice-It

needs to use the name "equals" for another purpose, so we'll call it "equals2" here.) The method accepts another binary tree of integers as a parameter and compares the two trees to see if they are equal to each other. For example, if variables of type IntTree called t1 and t2 have been initialized, then the call of t1.equals2(t2) will return true if the trees are equal and false if otherwise.Two trees are considered equal if they have exactly the same structure and store the same values. Each node in one tree must have a corresponding node in the other tree in the same location relative to the root and storing the same value. Two empty trees are considered equal to each other.You may define private helper methods to solve this problem, but otherwise you may not call any other methods of the class nor create any data structures such as arrays, lists, etc. Your method should not change the structure or contents of either of the two trees being compared.Assume that you are adding this method to the IntTree class as defined below:public class IntTree { private IntTreeNode overallRoot; ...}
Computers and Technology
1 answer:
masya89 [10]3 years ago
6 0

Answer:

public boolean equals(Object other)

{

// check correct instance

if (other instanceof IntTree)

{

try

{

IntTree otherTree = (IntTree) other;

return equals(overallRoot, otherTree.overallRoot);

}

// caught exceptions

catch (Exception e)

{

return false;

}

}

return false;

}

public boolean equals(IntTreeNode tree1, IntTreeNode tree2)

{

// if reach ends

if (tree1 == null && tree2 == null)

{

// they are equal

return true;

}

else if (tree1 == null || tree2 == null)

{

// not equal

return false;

}

// check left part

boolean leftPart = equals(tree1.left, tree2.left);

// check current element is same

boolean currentPart = tree1.element.equals(tree2.element);

// check right part

boolean rightPart = equals(tree1.right, tree2.right);

// all are equal

return (leftPart && currentPart && rightPart);

}

Explanation:

You might be interested in
Fill in the blank to complete the sentence. -------------------- is used to store and process data over the Internet using compu
Trava [24]

Answer:cloud computing

Explanation:

6 0
3 years ago
A developer needs to create a visualforce page that displays case data. The page will be used by both support reps and support m
shutvik [7]

Answer:

B. Use a new support manager permission sets

Explanation:

According to the requirements, field level security is required so, 1st options is not suitable because it may reduce the maintenance cost but increase the risk of security.

By creating a separate page for each of the two, it will leads to increase in the maintenance cost of the system. So <u>Option C</u> is also not suitable.

Option B is more Suitable as compared to others, that <em>Create a new support manager permission set</em>, with the help of this, both of Support rep and Support manager can visualize their required information with the help of support manager permission. This solution will not compromise the security and not increase the maintenance cost.

7 0
3 years ago
Which are three possible text formatting actions in wordpad?
DaniilM [7]

Answer:

Font, Bold, italic, colored, centered text...

7 0
3 years ago
In cell g6, enter a formula that calculates the discount rate for the off-peak rental price per day. for example, using the peak
Tresset [83]

The peak rentals  per day values are 149.95  

the off peak rentals per day values are 120.


formula must start with = because it is in excel

3 0
3 years ago
What is information systems​
maxonik [38]

brainly.com/question/10887381

Answer:You need 7 bits to encode everything that could be typed on this keyboard.

Explanation:

The encoding of the QWERTY keyboard is based on the extended ASCII encoding. The "ASCII" code was created by the "American standards association" in 1963.The acronym of “American Standard Code for Information Interchange” is ASCII. ASCII is a 7-bit  code.

Further Explanation:

The QWERTY keyboard is the standard computer and typewriter keyboard design for Latin-script alphabets. The first six letters of the keyboard's upper row indicate its name.  Christopher Latham Sholes designed the layout of the keyboard for his "Type-Writer".  It was first mass-produced in 1874.

In QWERTY keyboard, extended American Standard for Information Interchange (ASCII) method is used for characters encoding. Alphabetical order of English language is the base of ASCII method of characters encoding.  

Learn More:

Learn more about QWERTY keyboard: brainly.com/question/649081; Answered by: Jessusulas

Learn more about ASCII: brainly.com/question/7851735; Answered by: LearnGrow

Keywords:

QWERTY keyboard, The encoding of the QWERTY keyboard, American Standard for Information Interchange, ASCII

6 0
3 years ago
Other questions:
  • Write a C++ program that searches for anagrams in a dictionary. An anagram is a word obtained by scrambling the letters of some
    5·1 answer
  • Because you do not know every possible future use for the data TerramEarth collects, you have decided to build a system that cap
    15·1 answer
  • You are the owner of a movie theater upgrading to digital film, and are concerned about the cost of buying new digital equipment
    5·1 answer
  • Assign testResult with 1 if either geneticMarkerA is 1 or geneticMarkerB is 1. If geneticMarkerA and geneticMarkerB are both 1,
    11·1 answer
  • Cell height can be changed by. Select all that apply
    15·2 answers
  • Which of the following best explains the concept of a prototype
    10·1 answer
  • What are the benefits of building blocks?
    8·2 answers
  • The algorithm ____ is used to find the elements in one range of elements that do not appear in another range of elements.
    5·1 answer
  • Cloud suites are stored on your hard drive and are available anywhere you can access the Internet
    15·1 answer
  • How can knowing internal and external parts of computer help me
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!