I am now completely lost. I thought i had the correct algorithm to solve this problem, but i can't seem to get it. Anyone have any ideas. I need to balance the parentheses and print each level.
Ex: (this + (is) + an + example)
It will go through it and when it hits a left ( it will call itself again and increment the level.
so it will go up to (this + ( and call itself and kind of start all over until it finds a ). So it gets to (is) and then it exits the loop going through the characters and it prints
(is) from func, level 2
Then when it goes back it will need to start at (this + (is) and continue on like normal until the end so it should print
(this + (is) + an + example) from func, level 1
So overall it would look like
(is) from func, level 2
(this + (is) + an + example) from func, level 1
The problem i am having is when jumping back up to the first level i need to skip over the second level one i just scanned and start up again from after that. I need to keep track of the number of characters ive gone through so far. So in this case it would stop at 8 characters and when i go back to level one i need to start at the 11th character (so 8 (the previous number of chars) + 3 (chars from the recursive call)) and i am not sure how to accomplish this.
Hope thats clear. And by the way i am using MIPs
-Thanks