Converting an expression to conjunctive normal form with a twist

眉间皱痕 提交于 2019-12-06 11:31:10
HerdplattenToni

I'd use two iterations over the tree, although it's probably possible in one.

First iteration: get rid of your NOT Nodes by walking through the tree and using De Morgan's law (wikipedia link) and remove double negation wherever applicable.

Second iteration (the NOT are now only directly before a leaf node) Go through your tree:

Case "AND NODE":
    fine, inspect the children
Case "OR NODE":
    if there is a child which is neither a Leaf nor a NOT node
        apply the distributive law.
        start from parent of current node again
    else
        fine, inspect children

After that you should be done.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!