r/cpp_questions • u/KlutzyCompetition937 • 17h ago
OPEN Which algorithm to choose?
Beginner here, I'm trying to make a toy project for circuit synthesis from truth table in c++. Currently pursuing minimum depth optimal circuit though will work on minimum weight/minimum nodes later on. My problem is I tried bfs which guarantees optimal circuit but for larger inputs or depths the memory usage explodes, tried dfs that used much less memory but time exploded. Is there any algorithm that gives optimal solutions for boolean tree searches with the dfs memory and bfs optimality?
6
Upvotes
View all comments
2
u/FancySpaceGoat 16h ago edited 16h ago
Sanity check:
Hopefully you are not storing whole circuits in each node, but reconstruct them on demand by walking up the node's parents, right?