Click here to Skip to main content
15,887,267 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
i am giving a task to implement the rabin karp algorithm in c#.
i have searched alot over internet, but could not find the implementation of rabin karp algorithm in c#.
Anyone can help me in this regard

thanks in advance
Posted
Comments
Sergey Alexandrovich Kryukov 29-Apr-13 13:12pm    
You are giving — whom?..
Let me guess... Never tried to do anything?
—SA
Member 10018000 29-Apr-13 13:29pm    
Thanks for your quick reply, but my question is not anewered properly. The link you give have the following code, which is not in my understanding.... could you please implement in c#:

function RabinKarp(string s[1..n], string sub[1..m])
hsub := hash(sub[1..m]); hs := hash(s[1..m])
for i from 1 to n-m+1
if hs = hsub
if s[i..i+m-1] = sub
return i
hs := hash(s[i+1..i+m])
return not found
Sergey Alexandrovich Kryukov 29-Apr-13 15:00pm    
What do you mean "properly"? Doing all your job for your? No, my answer is quite proper, if you follow it, you will solve your problem.
—SA

1 solution

If you have to implement the algorithm in C#, implement it in C#, don't try to find the implementation. Especially if you have everything to do it, including the pseudo-code:
http://en.wikipedia.org/wiki/Rabin%E2%80%93Karp_algorithm[^].

What else would you need? Hash? It is put in the very root of the .NET type system:
http://msdn.microsoft.com/en-us/library/system.object.gethashcode.aspx[^].

—SA
 
Share this answer
 

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