A programmer has written the following methods, which are supposed to insert an int into an OBT, and return the depth of an OBT respectively. Unfortunately there are some errors. Assume appropriate definitions for the instance variables empty, value, left and right, and the method setValue(), as shown in COMP16212.
public void insert(int insertValue)
{
}
public int getDepth()
{
else
{
} }
if (empty) setValue(insertValue);
else if (insertValue < value) left.insert(insertValue);
else right.insert(insertValue);
if (empty) return 0;
int leftDepth = left.getDepth(); int rightDepth = right.getDepth(); if (leftDepth > rightDepth)
return leftDepth + value; else
return rightDepth + value;
He or she creates an OBT by starting with an empty one, and inserting the numbers 15, 12, 8, 13, 20, 16, 25 in that order. What value would be returned by the getDepth() method, if it was invoked on the root node of the resulting tree?