function [correct,precision,recall] = CS5300_DT_correct(nodes,x,y)
%

num_x = length(x(:,1));
err = 0;
retrieved = zeros(num_x,1);
for e = 1:num_x
    a =  CS5350_tree_decide(nodes,x(e,:));
    res(e).vals = a;
    if length(a)>1|(length(a)==1&a==1)
        retrieved(e) = 1;
    end
end
err = 0;
for e = 1:num_x
    if isempty(find(y(e)==res(e).vals))
        err = err + 1;
    end
end
err = err/num_x;
correct = 1 - err;
relevant = find(y==1);
retrieved = find(retrieved);
num = intersect(relevant,retrieved);
if isempty(retrieved)
    precision = 0;
else
    precision = length(num)/length(retrieved);
end
if isempty(relevant)
    recall = 0;
else
    recall = length(num)/length(relevant);
end
