normalwidth = 400;
normalheight = 100;
function displayarray(a, rec, showfurthest) {
/* assumes that elements are in [0, 255] */
var i, lastpos, thispos, val, width;
lastpos = 0;
width = normalwidth/a.length;
document.write('<table border="2" width="',
normalwidth+normalheight/2,
'"><tr><td style="text-align: center">');
for (i=0; i<a.length; i++) {
thispos = Math.round((i+1)*width);
val = thispos-lastpos;
document.write('<img src="pix.png" width="', val, '" height="', Math.round((a[i]+1)/256*normalheight),
'" />');
lastpos += val;
}
if (rec) {
document.write('</td></tr><tr><td style="text-align: center">',
'N = ', a.length, ', ',
rec.iter ? ('iter = ' + rec.iter + ', ') : '',
'comparisons = ', rec.ncompare, ', ',
'swaps = ', rec.nswap,
rec.bound ? (', bound = ' + rec.bound) : '',
rec.lowerbound ? (', lowerbound = ' + rec.lowerbound) : '',
rec.furthestswap && showfurthest ? (', furthest swap = ' + rec.furthestswap) : '',
'</td></tr><tr><td style="text-align: center">');
}
document.write('<p>', a.join(', '), '</p>');
document.write('</td></tr></table>');
}
