I believe at this point, I have found the (one of) the most efficent ways to sort the angle bracket strings accordingly. It turns out that the previously rejected IPF is infact useful in the solution to this problem.
Before I go into detail about all of this, let me present a table with my findings:
| “>_<” | “>>_<<” | ">>>_<<<” | “>>>>_<<<<” |
Start String -> IPF | ><_ | >_><< ><>_< ><><_ | >>_><<< >><>_<< >><><_< >><_<>< >_<><>< _><><>< | >>>_><<<< >>><>_<<< >>><><_<< >>><_<><< >>_<><><< >_><><><< ><>_><><< ><><>_><< ><><><>_< ><><><><_ |
IPF -> OPF | <>_ | ><_<> _<><> | <>_><>< <><>_<> <><><>_ | ><><><_<> ><><_<><> ><_<><><> _<><><><> |
OPF -> Solution | <_> | <_><> <<>_> <<_>> | <><><_> <><_<>> <_<><>> <<_><>> <<<>_>> <<<_>>> | <_><><><> <<>_><><> <<><>_><> <<><><>_> <<><><_>> <<><_<>>> <<_<><>>> <<<_><>>> <<<<>_>>> <<<<_>>>> |
This chart shows the most efficent ways (I could find) of arriving at the solution, for 4 pairs of strings that (increment by one set of <> brackets). The solution I use has the following process:
Start String -> Inward Paired Form -> Outward Paired Form -> Solution
Immediately, the problem of insufficient cleverness arises. How do I know this is the most efficent way to obtain a solution? To be honest, I don't. I there are other cases I could have checked (although, I checked many). I found this method to be fairly straightforward; furthermore: to make the solutions even more efficient after this point became fairly difficult. Because (unlike other, random methods), the one above is easy to conceptualize, in addition to appearing highly efficent, I choose it for my final solution.
Because I am letting the above method be my final solution; I can answer the second part of the question to this problem: What is the minimum number of moves needed for an n bracket string?
Because of the conceptualization of this problem, steps can be fairly easily counted. Let every move be one step. Then, the total number of moves for an arbitrary string of angle brackets is:
| Start String -> IPF| + | IPF -> OPF| + |OPF -> Solution|
Where "||" indicates the number of moves for each process. Let us consider each process in turn:
1) | IPF -> OPF|:
From the table, it can easily be seen that for n sets of brackets, n moves are needed for this step in the solution. Then simply, f(n) = n here.
2) |Start String -> IPF| AND |OPF -> Solution|
A glance at the table shows that both processes have the same number of steps. If f is a function that represents the number of steps for each sub-process, then:
f(0) = 0
f(1) = 1
f(2)= 3
f(3) = 6
f(4) = 10
which results in the following recursive formula:
{ n n = 0, 1 |
f(n) = { |
{ f(n-1) n >= 2 |
We can unwind the formula accordingly....
f(n) = f(n-1) + n
= [f(n-2) + (n-1)] + n
= [f(n-3) + (n-2)] + (n-1) + n
.......
= [0 ] + 1 + 2 .....n
Simply, the sum from 1 to n. So then f(n) = n(n+1)/2 .
-------
Then, our final formula for | Start String -> IPF| + | IPF -> OPF| + |OPF -> Solution| is:
f(n) = 2(n(n+1)/2 ) + n
= n(n+1) + n
= n^2 + 2n
If I have time, I will give some proofs of my findings. That is all, for now.