I have some doubts when creating a tree in java, need to create a tree to save data of students with a maximum of 3 notes each and an id for each student. I also need you to enter a note in particular a left node show me all students who have a grade below the entered and the right node which they are most to that note. Someone could help me? I have the structure of the student and the node but I feel a bit tricky to insert nodes with their students
student
public class Alumno {
private String rut;
private String[] notas;
public Alumno(String rut, String[] notas) {
this.rut = rut;
this.notas = notas;
}
public Alumno(){
}
public String getRut() {
return rut;
}
public void setRut(String rut) {
this.rut = rut;
}
public String[] getNotas() {
return notas;
}
public void setNotas(String[] notas) {
this.notas = notas;
}
@Override
public String toString() {
return "Alumno{" + "rut=" + rut + ", notas=" + notas + '}';
}
}
Node
public class Nodo {
private Alumno dato;
private Nodo izquierdo;
private Nodo derecho;
public Nodo(Alumno dato){
this.dato = dato;
}
public Nodo getNodoIzquierdo(){
return izquierdo;
}
public Nodo getNodoDerecho(){
return derecho;
}
public void setNodoIzquierdo(Nodo nodo){
izquierdo = nodo;
}
public void setNodoDerecho(Nodo nodo){
derecho = nodo;
}
}