<![CDATA[Java Programming Forums - The Java Community - Algorithms & Recursion]]>
http://www.javaprogrammingforums.com/
enTue, 09 Feb 2016 22:27:12 GMTvBulletin60http://www.javaprogrammingforums.com/images/misc/rss.png<![CDATA[Java Programming Forums - The Java Community - Algorithms & Recursion]]>
http://www.javaprogrammingforums.com/
Find spesific subtree
http://www.javaprogrammingforums.com/algorithms-recursion/46795-find-spesific-subtree.html
Mon, 08 Feb 2016 10:23:28 GMTI have a set theory formula that has 2 similar subformulas in it. Lets say it has A/B at different locations. I have a Textfield where i can see the...I have a set theory formula that has 2 similar subformulas in it. Lets say it has A/B at different locations. I have a Textfield where i can see the formula and i can select subformulas from it. For each subformula i must save something. Problem is, if i select A/B how do i get the correct A/B.

I currently have a solution where i check for position. Wile parsing formula to tree i save the position of each element to the nodes i create.
But now i have a problem where i cant use this solution anymore, because i need to be abel to modify the tree. EX: i have formula A U B U C. A B and C are subformulas. A/B are located inside A and C. My program will allow(once i get this working) to select pieces of formula form different places, if they are part of same n-ary operation. so. A U B U C, here i select A U C.

New tree will be A U C U B. Now my position method doesn't work anymore.

I had an idea where i can maybe dynamically track the position. But the problem is, that the root node can be anywhere, and each time counting the node location after i change the tree is not efficient i think.

Also if i have a tree C U A U C U A and i have solved both C U A-s il have a tree (C U A) U (C U A). How to i match this new tree with tree that is ((C U A) U C) U A?

Anybody have an idea how i can get the correct subtree ?
]]>vastrolordehttp://www.javaprogrammingforums.com/algorithms-recursion/46795-find-spesific-subtree.htmlsingly linked list counting algorithm
http://www.javaprogrammingforums.com/algorithms-recursion/46651-singly-linked-list-counting-algorithm.html
Mon, 18 Jan 2016 21:38:57 GMTHi,
I need to write a metod that goes over a non sorted singly linked list and returns the number that appears the most times but goes over the...Hi,

I need to write a metod that goes over a non sorted singly linked list and returns the number that appears the most times but goes over the list only one time.

Can someone point me in the right direction?

Can't find an elegent solution yet, should I use recursion?

I want the code to be as efficient as possible.

Thanks in advance.
]]>nadavelhttp://www.javaprogrammingforums.com/algorithms-recursion/46651-singly-linked-list-counting-algorithm.html