I have a recursive Java method that builds a binary tree:
BT build() {
return(a[++k] == 0 ? null : new BT(build(), build()));
}
BT is a class that looks like this:
class BT {
BT L; BT R;
BT(BT l, BT r) {
L = l; R = r;
}
}
How does the build class work? If I wanted to build a tree with N nodes, then how many times would the build function be called in terms of N?
buildclass? Do you meanbuildfunction?aandkare never passed as arguments and are not declared. I'm assuming those are class variables you haven't shown?