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
________ refers to the ICT architecture, where users access software applications and information systems remotely over the Inte
Slav-nsk [51]

Answer:

Cloud computing

Explanation:

Cloud computing refers to the process of making computer system resources like computing power and data storage available to user on-demand without requiring the user to manage them himself. The computer system resources include servers, applications, networks, services, storage, and others.

It allows data center to be available over the internet to a large number of users.

Cloud computing involves employing a network of remote servers which are hosted on the Internet for processing, storing, and managing data, instead of using a personal computer or a domestic server. Its aim is to ensure a coherence and economies of scaled through resources sharing.

There are two types of cloud computing: enterprise clouds, which its use can be restricted to just one organisation; and public cloud, which is meant for many organisation.

3 0
3 years ago
Give an original idea for an app idea to do with sports, please.
BlackZzzverrR [31]
Maden Mobile is an app for sports :)
5 0
4 years ago
The music is the soul who says this
Crazy boy [7]

Question:the music is the soul who says this

Answer: Arthur Schopenhauer

Explanation: he says music is the language of feeling and of passion

question answered by

(jacemorris04)

4 0
3 years ago
ASCII is a common format for the representation of characters in writing code. How many characters can be represented in the sta
andreyandreev [35.5K]

Answer:

A total of 128 characters can be represented in the standard ASCII encoding.

Explanation:

The American Standard Code for Information Interchange (ASCII) was created to make an international standard for encoding the Latin letters. In 1963, ASCII was received so data could be deciphered between PCs; speaking to lower and upper letters, numbers, images, and a few orders.

Since ASCII is encoded using ones and zeros, the base 2 number framework, it uses seven bits. Seven bits permits 2 to the power of 7 = 128 potential blends of digits to encode a character.

ASCII consequently ensured that 128 significant characters could be encoded.

4 0
3 years ago
List 7 internal components in a computer system
MrRa [10]
Motherboard
processor
graphic card
memory
storage
power supply
sound card
6 0
3 years ago
Read 2 more answers
Other questions:
  • Is Bluetooth considered a computing innovation?
    8·1 answer
  • _____ are networks that learn and are capable of performing tasks that are difficult with conventional computers.
    11·1 answer
  • A pointer is the memory address of a variable. FALSE TRUE
    9·1 answer
  • Write a loop that displays all possible combinations of two letters where the letters are 'a', or 'b', or 'c', or 'd', or 'e'. T
    15·1 answer
  • Howard’s In The Process Of Creating A Google Display Campaign And Decides To Use Custom Intent Audiences As A Targeting Option.
    5·1 answer
  • Which of the following is a negative effect of the rise in agricultural technology following World War II?
    5·1 answer
  • When performing the ipconfig command, what does the following output line depict if found in the tunnel adapter settings?
    5·1 answer
  • Edhesive 7.2 code practice Write a function named ilovepython that prints out I love Python three times. Then, call that functio
    13·1 answer
  • What is a worm?
    11·1 answer
  • You plays pokemon go
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!