Algorithm for converting a normal boolean expression to a NAND form expression

  Kiến thức lập trình

Actually I want to implement logic circuit using only NAND gates. So I have to convert the given expression to an expression which is suitable for NAND gate implementaion. Is there any optimized algorithm to do it?I want the minimum number of gates. I want to do it using any programming language.

I have tried a method that is not optimized. I just replace the not gate using 1 nand gate, replace the and gate using 2 nand gates and replace a or gate using 3 nand gate. There is a traditional method to do it adding extra not gate with the overall expression. Then remove all the or gates using de-morgan’s law. But I have no idea how to implement it in coding.

New contributor

Istiak is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.