n = |S|, m = |Si|
The amount of work done at each full level of the function call tree is nm.
In the worst case the tree has depth n.
So the worst case running time
is O(n2m) (It actually works out to n2/2)
This is almost identical to
the complexity analysis
of quicksort.