function showMyCache(bp)
%Recursively calls itself to display a "slice" from the cache representing
%one busy period. The triangular tables for g(.) and then h(.) are shown.
global cache free
disp('Triangular table for function G');
oneTriangle(1,bp,1);
disp('Triangular table for function H');
oneTriangle(1,bp,0);
end

function oneTriangle(loc, bp,isG)
%Recursive function to display the triangular "slice" from the persistent cache
%table starting from node "loc" with remaining packet lengths in vector "bp".
%If logical parameter "isG" is true then display g(.), else display h(.).
global cache free
rightChild=doesChildExist(loc,bp(1));
if rightChild ==-1
    disp('Something is wrong - Cache doesn''t support this busy period!');
    return
end
if numel(bp)>1 % Handle the remainder of bp before displaying this cache row
    oneTriangle(rightChild, bp(2:end), isG);
end
indentLevel =blanks(cache(loc).i*11);
fprintf('%3u:%s ', rightChild, indentLevel);
if isG
    fprintf(' %10.4g',cache(rightChild).g(1:numel(bp)));
else
    fprintf(' %10.4g',cache(rightChild).h(1:numel(bp)));
end
fprintf('\n');
end