The main reason that i registered in this forum is to learn and communicate with other java programmers. This days I'm working on one assigment that has as purpose to create a Binary Search Tree that read a text files(which contains a String name and a double number) and implements some methods. Unfortunately i'm not very familiar with BST so I'm facing some difficulties. At the moment i want to write a method to search the BST to find and return the largest number. At the moment i'm using this code to do that but unfortunately i receive only the first number of the list and not the actual largest. Here is my method
Can anyone help me or advice me with this method?private double FindMaxElement(TreeNode maxElement) { double max = 0; if(maxElement != null) { if(maxElement.number > max) { max = maxElement.number; FindMaxElement(maxElement.left); FindMaxElement(maxElement.right); } } return max; }