Quantcast
Channel: LabVIEW topics
Viewing all articles
Browse latest Browse all 68863

Extract balanced parantheses from String

$
0
0

Hi community,

 

I am getting back to work on LabVIEW after long.

Currently implementing an algorithm and I need to work with tree like structures presented in the form of strings with parantheses.

So, for example, a string such as A(B(c,d),P(q,r),U(V(w),X(y,z,o))) has a tree with root node A, and there are three children of A, namely B, P, U, and all of them also represent a tree (sub-tree of the original tree A). So that, B is the root of the sub-tree where c and d are the two nodes. U also has two children that represent individual sub-trees, namely V (with one child) and X (with three children).

Tree from string.png

 

Although, there is one detail, which may actually help the process a bit. The trees are simplified, so that all the nodes that represent some tree (or sub-tree) are just called S.

 

Tree from string-simplified.png

 

To extract all these trees, I am going to check one element at a time and then build the sub-trees one by one.

Just thought to ask here if someone has a better idea (or if some function from OpenG may help here if someone has done something similar). Always ready to learn!

 

Thanks ahead!


Viewing all articles
Browse latest Browse all 68863

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>