Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

>> REGISTER NOW TO START POSTING

# Thread: Data Structures: Symbolic Algebra with Trees

1. ## Data Structures: Symbolic Algebra with Trees

So, I will soon be a student at a University studying Computer Science, and I have taken it upon myself to study ahead for my Data Structures class. I am currently on the 7th week of assignments, and we have been working in Java using a class named Cons which represents the same cons structure in Lisp. If you don't know what a cons is -> cons - Wikipedia, the free encyclopedia

So this is an assignment, and I understand the policy with receiving help on assignments, but I'm simply looking for guidance. The basic structure for a tree that's represented as an equation is:
```             =
/  \
x    -
/  \
y    z```
This is just a very simple representation of an equation, but the other test cases are much more involved. For a function, Cons solve(Cons e, String v), return the part of the equation that is equal to the String v. So if you pass in the Cons illustrated with the String x, you would simply return the e since x = y - z, but if I was looking for String y, you would return a Cons that has y = x - z, but represented as a tree of Cons.

If anyone is familiar with Cons/Lisp and has any guidance, that would be awesome. I'm having a hard time understanding how to rotate the tree to resemble basic Algebra. This may be a long-shot, but help would be greatly appreciated. The last few posts about unrelated topics didn't really receive much feedback at all.

2. ## Re: Data Structures: Symbolic Algebra with Trees

I'm having a hard time understanding how to rotate the tree to resemble basic Algebra
The tree is just another way to express the equation. Everything works just as it does in algebra.
To keep the equation in balance, what you do to the left side of the = must also be done to the right side.
I don't understand exactly what it is that you dont understand.

3. ## Re: Data Structures: Symbolic Algebra with Trees

Yeah, I didn't really know how to word what the issue was.. But I believe I just solved the problem. I was just having an issue visualizing what was really going on whenever you preformed the "algebra". Thanks for the reply, but I'm good now.