Click here to Skip to main content
15,887,135 members
Home / Discussions / C#
   

C#

 
AnswerRe: Path stripping algorithim.....help required Pin
Judah Gabriel Himango10-Sep-07 4:59
sponsorJudah Gabriel Himango10-Sep-07 4:59 
AnswerRe: Path stripping algorithim.....help required Pin
Skippums10-Sep-07 5:15
Skippums10-Sep-07 5:15 
GeneralRe: Path stripping algorithim.....help required Pin
c#_keithy10-Sep-07 5:43
c#_keithy10-Sep-07 5:43 
GeneralRe: Path stripping algorithim.....help required Pin
Skippums10-Sep-07 5:48
Skippums10-Sep-07 5:48 
GeneralRe: Path stripping algorithim.....help required Pin
Guffa10-Sep-07 6:04
Guffa10-Sep-07 6:04 
GeneralRe: Path stripping algorithim.....help required Pin
Skippums10-Sep-07 7:06
Skippums10-Sep-07 7:06 
AnswerRe: Path stripping algorithim.....help required Pin
Luc Pattyn10-Sep-07 7:12
sitebuilderLuc Pattyn10-Sep-07 7:12 
GeneralRe: Path stripping algorithim.....help required Pin
Skippums10-Sep-07 8:22
Skippums10-Sep-07 8:22 
I don't think that this algorithm will be faster in most cases. Here is why I think so:

1. The StartsWith will compare at most the length of common, but at least as much as the length of the match

2. LastIndexOf will compare the difference between the current guess at the common string and the next guess at the common string

3. Taking the substring will require the length of common to copy.

So the only time that I can think of where this algorithm would save time would be if you have two non-matching directories that start identically, such as "Food for thought" and "Food for thomas", and those are the ONLY directories you are comparing. Assuming that this is not the case (typical, since there are thousands of entries), the other way cuts out the expenses from parts 2 and 3. The other issue that I see with this is that if you have 3500 paths, and the first 200 fall into a directory that is NOT going to end up as the common directory, you spend a lot of extra time being told that these directories in fact do match a directory that doesn't matter. I also think that directory names in windows are case-sensitive, so the suggestion on making the comparison case-insensitive is unnecessary and takes more time (since you have to then convert the chars to lowercase). One thing that I do like is the suggestion to compare the first and last if they are already sorted (doubtful since you don't already know the common directory). The assumption made as to the efficiency of this algorithm also depends on the collection being "roughly" sorted, that is that the first and last directories differ significantly, which will reduce the amount of time wasted on using "StartsWith". Anyway, those are the reasons that I would stick with the other algorithm myself.

Jeff
GeneralRe: Path stripping algorithim.....help required Pin
Luc Pattyn10-Sep-07 9:53
sitebuilderLuc Pattyn10-Sep-07 9:53 
GeneralRe: Path stripping algorithim.....help required Pin
Skippums10-Sep-07 10:08
Skippums10-Sep-07 10:08 
GeneralRe: Path stripping algorithim.....help required Pin
c#_keithy10-Sep-07 21:57
c#_keithy10-Sep-07 21:57 
QuestionHelp with DataGridViewTextBoxColumn Pin
gugulethun10-Sep-07 3:47
gugulethun10-Sep-07 3:47 
AnswerRe: Help with DataGridViewTextBoxColumn Pin
mr.mohsen10-Sep-07 4:57
mr.mohsen10-Sep-07 4:57 
QuestionWindow Service Error Pin
ramdil10-Sep-07 2:56
ramdil10-Sep-07 2:56 
AnswerRe: Window Service Error Pin
Nissim Salomon10-Sep-07 3:43
Nissim Salomon10-Sep-07 3:43 
GeneralRe: Window Service Error Pin
ramdil12-Sep-07 23:41
ramdil12-Sep-07 23:41 
QuestionNeed help with time math calculation Pin
RapGame200610-Sep-07 2:38
RapGame200610-Sep-07 2:38 
AnswerRe: Need help with time math calculation Pin
Colin Angus Mackay10-Sep-07 2:41
Colin Angus Mackay10-Sep-07 2:41 
GeneralRe: Need help with time math calculation Pin
RapGame200610-Sep-07 4:52
RapGame200610-Sep-07 4:52 
Questionreterive Xml attribute values [modified] Pin
M.A.Burhan10-Sep-07 2:14
M.A.Burhan10-Sep-07 2:14 
AnswerRe: reterive Xml attribute values Pin
pmarfleet10-Sep-07 2:47
pmarfleet10-Sep-07 2:47 
QuestionChat program for Wan Pin
sandipan.neogi@gmail.com10-Sep-07 2:09
sandipan.neogi@gmail.com10-Sep-07 2:09 
AnswerRe: Chat program for Wan Pin
c0ax_lx10-Sep-07 4:47
c0ax_lx10-Sep-07 4:47 
QuestionHow to installl setup.exe for every machine Pin
ASysSolvers10-Sep-07 1:15
ASysSolvers10-Sep-07 1:15 
AnswerRe: How to installl setup.exe for every machine Pin
Pete O'Hanlon10-Sep-07 1:31
mvePete O'Hanlon10-Sep-07 1:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.