function y = classTree(Tree,X)
% y = classTree(Tree,X)
%
% Tree decision tree returned by learnTree
% X examples to classify
%
% Classifies examples X and returns labels y.

if nargin < 2
	error('Too few input parameters.');
end
n = size(X, 1);
y = ones(n, 1);

for k = 1:n
	i = 1;
	while Tree.attr(i) > 0
        % find child nodes
		j = find(Tree.nodes == i);
		if length(j) < 2
			% no child nodes (leaf)
            break
		end
		if X(k,Tree.attr(i)) > 0
			% left node 
			i = j(1);
		else
			% right node 
			i = j(2);
		end
	end
	y(k) = Tree.class(i);
end
