Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
CHRTRAN and remove characters
Message
 
 
To
13/10/2004 11:39:01
General information
Forum:
Visual FoxPro
Category:
Visual FoxPro Beta
Miscellaneous
Thread ID:
00950654
Message ID:
00951095
Views:
18
Fabio,

Your "do not move anything" assumption is not right, it is not how the current code works. It would require moving AAAAABB, then AAAAAB, then AAAAA.

There do exist other input strings that require more movement when proccessed right to left, it is a shame that you don't see this fact.

But the whole underlying fallacy of moving the same character more than once in any algorithm is what makes it O(n2), which is a foolish waste of CPU time when it can be done O(n) as I've posted in the C++ code.

>>Fabio,
>>
>>>???? David, I have some doubt
>>
>>Sure, in that one particular case moving right to left there are less moves in the brute force method.
>>
>>Remove B from this string: AAAAABBB. Left to right can be done in 3 moves. Right to left requires 18 moves in the brute force method you propose.
>
>Incredible !
>
>Left to right is done with 3 moves.
>My right to left is done with 0 moves !
>
>
>Step 1 'AAAAABBB' remove righ B and do not move enything
>Step 2 'AAAAABB' remove righ B and do not move enything
>Step 3 'AAAAA' remove righ B and do not move enything
>End
>
>
>>
>>But in general processing the string left to right or right to left is equivalent.
>>
>>If you'd take a bit of time to look at the C++ code on my page, the O(n) can be accomplished by realizing that as you process the string the character can be moved move than one position at a time. This is easily done via running an input pointer and an output pointer along the string.
df (was a 10 time MVP)

df FoxPro website
FoxPro Wiki site online, editable knowledgebase
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform