algorithm - Expression Trees C# for calculating logic equivalence -
recently have programmed recursion function constructing expression tree since expression ((a|b)^c). not problem, problem when time evaluate it, since final tree expression given in next form:
^ / \ | c / \ b
and problem raised when time evaluate applying corresponding logic equivalence(in case, distributive law). tried using algorithm evaluating tree if arithmetic expression tree:
evaluate(node) { if(node has children){ left_val = evaluate(node->left); right_val = evaluate(node->right); // find operation symbol node , use // val = left_val operation right_val return val; } else { return node_value; } }
but didn't succeed @ all, because couldn't values joined in distributive law's form. result, i'd decided better approach , came across approach of expression trees on c# but, i'm not sure if possible; , if it's possible, how can use expression:
a^c b^c
i don't know how expression tree works.
Comments
Post a Comment