subject

Java A perfect binary tree is a complete binary tree with all levels fully filled. Define a new class named BSTWithTestPerfect that extends BST with the following methods: (Hint: The number of nodes in a perfect binary tree is 2^(height+1) - 1.)

/** Returns true if the tree is a perfect binary tree */
public boolean isPerfectBST()

/* Please only use the following template to submit.
PLEASE ONLY USE THE PART BETWEEN BEGIN AND END ONLY

// BEGIN
class BSTWithTestPerfect extends BST {
/** Create a default BST with a natural order comparator */
public BSTWithTestPerfect() {
super();
}

/** Create a BST with a specified comparator */
public BSTWithTestPerfect(java. util. Comparator c) {
super(c);
}

/** Create a binary tree from an array of objects */
public BSTWithTestPerfect(E[] objects) {
super(objects);
}

/**
* Returns the height of this binary tree.
*/
public int height() {
return height(root);
}

private int height(TreeNode root) {
// WRITE YOUR CODE HERE
}

/** Returns true if the tree is a perfect binary tree */
public boolean isPerfectBST() {
// WRITE YOUR CODE HERE
}
}
// END

ansver
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 01:00, lusciousl
Petrică, tânăr licean în clasa a ix-a, a primit în dar de la părinţii săi un cont bancar pentru micile sale cheltuieli curente. el este pasionat de internet banking şi îşi verifică cu grijă toate tranzacţiile efectuate. pentru creşterea securităţii tranzacţiilor online, banca îi furnizează lui petrică un număr pe care el va trebui să îl modifice, obţinând un număr tan – număr de autentificare a tranzacţiei (transaction authentication number). regula de obţinere a numărului tan este următoarea: se formează cel mai mic număr par din toate cifrele numărului furnizat de bancă. cerinţă cunoscând numărul n furnizat de bancă, să se determine numărul tan obţinut de petrică. date de intrare fişierul tan. in conţine pe prima linie numărul natural n cu semnificaţia din enunţ. date de ieşire fişierul de ieşire tan. out va conţine o singură linie pe care va fi scris numărul tan cerut. restricţii • 0 < n < 18*1018 • n are cel puţin o cifră pară • numărul tan obţinut nu poate conţine zerouri nesemnificative
Answers: 2
image
Computers and Technology, 23.06.2019 07:30, cireland
Write a program that inserts the digits of an integer into an array in originalorderfollowed by reverse order. first, promptthe user to enter a positive integer(> 0). determine the number of digits of the integer. create a dynamically allocated integer arrayof a size twice the number of digits. now insert the digits in original order which will occupy half of the array. then, insert the digits in reverse order. finally, output thedigits in thearray. use at least two functions to organize your program.
Answers: 3
image
Computers and Technology, 23.06.2019 17:20, Morehollie9428
What is the best assassins creed game?
Answers: 2
image
Computers and Technology, 23.06.2019 17:30, kenyasutton10
What are the most commonly found items in the trash according to the municipal solid waste report?
Answers: 1
You know the right answer?
Java A perfect binary tree is a complete binary tree with all levels fully filled. Define a new cl...

Questions in other subjects:

Konu
Biology, 07.09.2021 23:50
Konu
Mathematics, 07.09.2021 23:50