Hey I have some work where I have to create a binary tree. Anyway I am stuck on one of the classes which has several methods I must fill in! can you please help me ?? The code is below
The methods I need help are below, the headers for each method are: public Node find (member p1)The method find(Member p1) is used to return the node which contains a particular member. It is a private method because the interface to CabinetTree should not provide direct access to the internal nodes. It makes use of the method Node findNode (Member p1, Node current)
and the next method is : Node findNode(Member p1, Node current) which searches the tree from current node to find a node whose value is equal to the Member p1, i.e. a node in the tree such that p1.equals(current.getMember()) is true. If there is no such node then the method should return null.
public class CabinetTree {
private Node head;
CabinetTree(Member p1) {
head = new Node(p1, null);
}
// changed to public for testing only
public Node find(Member p1) {
// to do
}
private Node findNode(Member p1, Node current) {
// to do
}
Aucun commentaire:
Enregistrer un commentaire