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
saul85 [17]
3 years ago
13

A perfect binary tree is a complete binary tree with all levels fully filled. Add a method in the BST class to return true if th

e tree is a perfect binary tree.
Computers and Technology
1 answer:
algol [13]3 years ago
6 0

Answer:

class BST {

static class Node

{

int val;

Node left, right;

}

static boolean checkPerfectBT(Node node, int h, int d)

{

if (node == null)

return true;

 

if (node.left == null && node.right == null)

{

if(h==d+1)

return true;

else

return false;

}

 

if (node.left == null || node.right== null)

return false;

 

return checkPerfectBT(node.left, h, d+1) && checkPerfectBT(node.right, h, d+1);

}

static int height(Node node)

{

int dep = 0;

while (node != null)

{

node = node.right;

dep=dep+1;

}

return dep;

}

static boolean isPerfectBT(Node node)

{

int h = height(node);

return checkPerfectBT(node, h, 0);

}

 

static Node addNode(int x)

{

Node node = new Node();

node.val= x;

node.right = null;

node.left = null;

return node;

}

public static void main(String args[])

{

int i,j,k;

Node node= null;

node = addNode(34);

node.left = addNode(2);

node.right = addNode(322);

 

node.left.left = addNode(21);

node.left.right = addNode(23);

node.right.left = addNode(37);

node.right.right = addNode(54);

 

if (isPerfectBT(node) == true)

System.out.println("This is a Perfect Binary tree");

else

System.out.println("This is Not a perfect Binary Tree");

}

}

Explanation:

  • Calculate the depth of BST by using a while loop until it reaches a null value.
  • In the addNode method, make an object of Node class.
  • In the main method, pass the values to addNode method.
  • Finally display the relevant message to show if it's Perfect or not.
You might be interested in
Who has pad let and wants to talk
vredina [299]

Answer:

I do.

Explanation:

8 0
3 years ago
Read 2 more answers
A(n) _____ can replace many applications with one unified set of programs, making the system easier to use and more effective.
umka2103 [35]
<span>A(n) ERP can replace many applications with one unified set of programs, making the system easier to use and more effective.

ERP stands for Enterprise Resource Planning system. It is a </span><span>set of integrated programs that manages vital business operations for an entire multi-site, global organization. It supports manufacturing & finance aspects of the organization. </span>
4 0
3 years ago
Which of these is not a combination of a keyboard and percussion musical instrument?
Sergio [31]

Answer:

The Harmonium is not a combination of a key board and percussion musical instrument.

Explanation:

The Harmonium is not a combination of a key board and percussion musical instrument.

A harmonium, also called a "melodeon", "reed organ" or "pump organ", is a keyboard instrument that is a lot like an organ. It makes sound by blowing air through reeds, which are tuned to different pitches to make musical notes.

3 0
3 years ago
"The _____ of the Open Systems Interconnection (OSI) model generates the receiver’s address and ensures the integrity of message
aleksklad [387]

Answer:

The transport layer

Explanation: Layer 4, is the transport layer of the Open System Interconnection (OSI), that handles message transfer of data between end systems or hosts and ensures complete packets transfer.

7 0
3 years ago
Read 2 more answers
Which three options below describe typographic hierarchy?
Korvikt [17]

The three options that describe the typographic hierarchy are given below:

  • The importance of information is shown through the text.
  • The presentation of the text in terms of structure.
  • The placement of the text defines its flow and hierarchy.

Thus, the correct options are A, B, and C.

<h3>What is Typographic hierarchy?</h3>

Typographic hierarchy may be characterized as an approach that utilizes typography: the size, font, and layout of distinct text components to produce a hierarchical division that can authenticate users where to look for specific information.

The purpose of using this methodology is to focus on the main points of the article accordingly. It increases the sense of understanding of the readers with focus.

Therefore, it is well described above.

To learn more about Typographic hierarchy, refer to the link:

brainly.com/question/12076206

#SPJ1

3 0
1 year ago
Other questions:
  • Regulatory control limits the activities of an organization in compliance with the organization's policies. True False
    14·2 answers
  • How to play music out of your apple watch?
    6·1 answer
  • How do I learn coding??? ​
    5·2 answers
  • Which of the following is a true statement?
    12·2 answers
  • For what purpose is keylogging software used? a. To automatically translate input to another language as the user enters data b.
    10·1 answer
  • If a switch needs to send information to other switches in the network it would send out a ___________.
    7·2 answers
  • Design an Application called Student Course Management create interface called Student Course add an abstract method called ad C
    10·1 answer
  • To delete unnecessary files on a hard disk use software
    5·2 answers
  • Explain how communication facilitate cordination​
    14·1 answer
  • Can some one help me with this please
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!