binary tree compare: multiple solutions solver

This commit is contained in:
2021-01-26 11:52:06 +01:00
parent 2e83f4b833
commit c1d0085217
3 changed files with 71 additions and 12 deletions

28
best.c
View File

@@ -61,14 +61,28 @@ int check_best(res, nops, node, values, ops)
nbests=0;
found=1;
//return 1;
} /*else if (diff == bestdiff && nops == bestops) {
# ifdef DEBUG_BEST
printf("NEW BEST SOLUTION (%d): res=%d diff=%d nops=%d\n", nbests+1, res, diff, nops);
print_node(node, TREE_TOP, 0, 0);
# endif
} else if (diff == bestdiff && nops == bestops) {
// if (nbests) {
found=2;
}*/
if (found==1) {
for (i=0; i<nbests; ++i) {
if (compare_nodes(node, bests[i].root, 0)) {
found=0;
break;
}
}
# ifdef DEBUG_BEST
if (found==2) {
printf("new diff solution (%d): res=%d diff=%d nops=%d\n",
nbests+1, res, diff, nops);
print_node(node, TREE_TOP, 0, 0);
} else {
printf("skipping duplicate solution (%d): res=%d diff=%d nops=%d\n",
nbests+1, res, diff, nops);
}
# endif
}
//}
if (found) {
set_timer(&(bests[nbests].timer));
bests[nbests].res=res;
bests[nbests].diff=diff;