Click here to Skip to main content
16,022,798 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
i am working on application which check .cs files for copy file by using krap rabbin algorithm which find whether P is a sub string of T or not. Assuming that P and T both are two source code and if P is a sub string of T then P is copied from T .. for efficiency how can we use linked list or tree in it?? in other word what data structure should be implement on it because i must implement data structure in this application and i am in learning process of data structure ..

here is rabbin 's algorithim

http://harvestsoft.net/rabinkarp.htm
Posted
Comments
Sergey Alexandrovich Kryukov 5-Dec-11 18:11pm    
Not clear. If you copy P = T.SubString(...), why do you need a search. Or, if you think is this is a special case of P being a substring of T, why would you think so? Even if you knew this a priori and if faster algorithm existed, how could it help in general case? what's your idea? I don't see if linked list or tree could help as you need to look through at least part of string character by character anyway.
--SA
saniaali 6-Dec-11 6:21am    
hmmm so what will help for this problem???
and my idea is to use hash function in krap algorithm or any other string matching algorithm because i am working on such application which need to use such algorithm apart from this how can i find out whether one file is copied or cheated from another source code file or not like Jplag, Sherlock , copy/paste detector do in thous application....
Sergey Alexandrovich Kryukov 6-Dec-11 16:50pm    
(Sigh...) please see my solution...
--SA

1 solution

Let me note that there is not such thing as "application which needs to use such algorithm"; the application may only have some requirements for result of application of one or another algorithm. You probably mean this: http://en.wikipedia.org/wiki/Rabin%E2%80%93Karp_algorithm[^]. So, what's the problem? The algorithm is clearly described and has nothing to do with list or tree structure — please see my comment to the question. I think I basically explained why.

Now, why won't you simply use System.String.Contains, LastIndexOf.System.String or System.String.LastIndexOf? See http://msdn.microsoft.com/en-us/library/system.string.aspx[^].

—SA
 
Share this answer
 
Comments
saniaali 8-Dec-11 14:54pm    
hmm got the idea, going to implement it thanks:)
Sergey Alexandrovich Kryukov 8-Dec-11 14:57pm    
You're welcome.
Good luck,
--SA
saniaali 8-Dec-11 16:53pm    
i have implemented robin's algo but for making it more efficient using rolling hash function...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900