Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static String alinea5(MorseTree tree, Morse a , Morse b){
- String common="";
- return alinea5b(tree.root(), a,b,common);
- }
- private static String alinea5b(Node<Morse> node, Morse a, Morse b,String common){
- if(node==null
- ||node.getElement()==a
- ||node.getElement()==b
- ||( a.compareTo(node.getElement() ) ) != ( b.compareTo(node.getElement() ) )){
- return common;
- } else{
- if(a.compareTo(node.getElement())<0 ){
- common = common + ".";
- return alinea5b( node.getLeft(),a,b,common);
- }else{
- common = common + "_";
- return alinea5b( node.getRight(),a,b,common);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment