Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Single occurrence in a string
Message
From
29/03/2015 07:48:56
 
 
To
29/03/2015 07:00:07
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Network:
Windows 2008 Server
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01617326
Message ID:
01617354
Views:
67
>This is the testing results of the 3 algorithms in my PC with a 50000 chars string:
>
>- Dragan: 52.5 secs and maintain the original order
>- Tore: 30.9 secs and doesn't maintain original order (order is alphabetical because SQL)
>- Marcia: 1.4 secs and maintain the original order => WINNER!
>
>Congrats Marcia! :D

>
>LOL!!!! So what is my prize?

The prize is a recognition of peer developers (me included) on your excelent strategy thinking.

Yesterday I was looking many times on the examples given, and even I tried to do an extra example to make a 4th option, but reviewwing all the algorithms I saw something in common:

- All gentleman code was based on brute force, on wich every iteration of the algorithm caused equal or more work in each step. In example, Tore's algorithm read all the info in a table and uses the SQL engine to order it, while Dragan's algorithm uses a variable on which in every iteration is bigger and the search of subtsr is longer

- Your algorithm, on the opposite side, is strategy, and you keep reducing the source string a lot in each step, so the next iteration the search work is less every time.

I was really amazed by your thinking on this question, and it is something te be learned.

Thanks for the lesson :)
Fernando D. Bozzo
Madrid / Spain
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform