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
What are static components in a multimedia system?
Zielflug [23.3K]

Answer:

Text (words)

Video (.mp4 or you tube)

Pictures (graphic)

Animations (gifs or short cartoon clips)

5 0
3 years ago
Read 2 more answers
An IT company has a HealthCare application with data security requirements such that the encryption key must be stored in a cust
babunello [35]

The S3 encryption, <u>Server-Side Encryption with Customer-Provided Keys (SSE-C)</u>, allows the company to leverage Amazon S3 for storing data with given constraints.

What do you mean by S3 encryption?
S3 encryption <u>encrypts your </u><u>data </u><u>when it is written to disks in its </u><u>data </u><u>centers at the </u><u>object </u><u>level and decrypts it for you when you </u><u>access </u><u>it.</u> There is no distinction between accessing encrypted or unencrypted items as long as you authenticate your request and you have access permissions.

S3 encryption<u> </u><u>encrypts an item before saving it to disk when you use server-side </u><u>encryption</u><u>; the </u><u>object </u><u>is then decrypted when you download the object</u>. S3 encryption lets you safeguard the data you store in AWS S3 buckets online, which is crucial for sensitive data.

To learn more about S3 encryption, use the link given
brainly.com/question/9979590
#SPJ4

4 0
1 year ago
True and False(Total points: 10)
Gwar [14]

Answer:

1.T 2.f 3.t 4.f 5.f 6.f 7.t 8.t 9.f

8 0
2 years ago
Read 2 more answers
______ devices are high-performance storage servers that are individually connected to a network to provide storage for the comp
natali 33 [55]
NAS - network attached storage
3 0
3 years ago
Which of the following is not a true statement? You can import a table or a query directly from an Access database into an Excel
Lilit [14]

Answer:

does anybody know this answer?

Explanation:

no nobody does

5 0
3 years ago
Other questions:
  • Which two technologies support the building of single-page applications?
    11·1 answer
  • John works for Internal Computer Specialists, which focuses on helping small business owners resolve MIS infrastructure issues.
    12·1 answer
  • 14. Convert 11110111 from binary to denary<br> (1 Point)
    12·2 answers
  • 2. Given the following list, write a snippet of code that would print the individual elements of the list using the indexes of t
    13·1 answer
  • Can someone help please
    12·1 answer
  • I will upvote....
    10·1 answer
  • The name of a person their address and their contact information like phone number and email address or consider the minimum inf
    9·1 answer
  • Activity
    7·1 answer
  • Normalization works through a series of stages called normal forms. For most purposes in business database design, _____ stages
    7·2 answers
  • Algorithm 1$ =RS 150<br><br>​
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!