Question description
ANSWER:
public boolean isBinarySearchTree() {
return isBST(root);
}
//helper method called by isBinarySearchTree
public boolean isBST(BinaryTreeNode tree){
…
}
ANSWER:
public boolean similarTrees(BinaryTreeNode otherTree) {
return similar(root, otherTree);
}
//helper method called by similarTrees
public boolean similar(BinaryTreeNode tree1, BinaryTreeNode tree2) {
…
}
3&4. Extend the class BinaryTree to include 2 more methods: nodeCount (count the number of leaves
in a binary tree) and leavesCount (count the number of nodes in a binary tree). Use recursion in both!
Add statements to the client program (lecture notes) to test these new added methods.
ANSWER:
public int treeLeavesCount() {
return leavesCount(root);
}
//helper method called by treeLeavesCount
private int leavesCount(BinaryTreeNode t) {
…
}
}
//helper method called by treeNodeCount
private int nodeCount(BinaryTreeNode t) {
…
}
Buy an essay in any subject you find difficult—we’ll have a specialist in it ready
Ask for help with your most urgent short tasks—we can complete them in 4 hours!
Get your paper revised for free if it doesn’t meet your instructions.
Contact us anytime if you need help with your essay
APA, MLA, Chicago—we can use any formatting style you need.
Get a paper that’s fully original and checked for plagiarism