Homework 10 - part 2 - } } return countNodes; } //page 732...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
// page 693 #7a public int count(T Object){ count(getRootNode(), Object); } private int count(Node rootNode, T Object){ int countNodes = 0; if (rootNode != null && Object != null ){ if (Object.equals(rootNode.data) countNodes = 1; else { countNodes = countNodes + count(rootNode.left, Object); countNodes = countNodes + count(rootNode.right, Object);
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: } } return countNodes; } //page 732 #15 public Object smallest(BinaryNode rootNode){ BinaryNode leftNode = rootNode.left; if (leftNode == null ) return (rootNode.data); else return smallest(leftNode); }...
View Full Document

Ask a homework question - tutors are online