Jump to content
xisto Community
varalu

Data Structures -- Expression Trees

Recommended Posts

Construct an expression tree for the expression (a || :rolleyes: && (c || d)

 

After constructing the tree convert the tree to correspond to the associative property of the given expression.

 

Eg: (1 + 2) * ( 3 + 4) = (1 * 3) + (1 * 4) + (2 * 3) + (2 * 4)

 

Similar to that, from the constructed expression tree, construct a new expression tree such that inorder traversal of the new tree will be associative value of the given expression

 

Inorder traversal of the new tree should be (a && c) || (a && d) || (b && c) || (b && d)

 

Write a generic algorithm to convert the first tree to the second tree..

 

What is an Expression Tree??

Visit links below.

http://www.brpreiss.com/books/opus5/html/page264.html

http://www.cs.jhu.edu/~goodrich/dsa/05trees/Demo1/

 

Tree Traversals

Visit the below links for knowing more about tree traversals.

https://en.wikipedia.org/wiki/Tree_traversal

http://www.brpreiss.com/books/opus4/html/page260.html

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.