function T = prune_tree(T,A,B,CF)
% PRUNE_TREE prunes the decision tree T using the pruning algorithm from 
%	C4.5: Programs from Machine Learning.
%
%	T = prune_tree(T,A,B,CF)
%
%	T : matrix representing decision tree generated by MSM-T algorithm
%	A: matrix representing the point set A
%	B: matrix representing the point set B
%	CF: certainty factor used in pruning.  0 <= CF <= 1.0
%
%	ASSUME: the root node will always remain

% coeff is a global variable and is accessible for function prune, prune_tree.

global coeff;
global CF;

% n is the dimension of the points in sets A,B
global n;
n = size(A,2);

% determine coeff:
coeff = prune_det_coeff(CF);

% prune the tree
% first determine T_breakdown
T_breakdown = msmt_tree_breakdown(T_breakdown,T,A,B,1);
position = [ 1 ];
[T,error] = prune(T,T_breakdown,0,[position,T(n+2,1)]);	% prune left
[T,error] = prune(T,T_breakdown,1,[position,T(n+3,1)]);	% prune right





