# Psuedo code to java, Finding a pattern in a suffix array?

**843853**Feb 17, 2010 5:43 PM

Hey I hope this is the right place for this....

I found the following psuedo code online, dealing with searching for a pattern in a suffix array:

I found the following psuedo code online, dealing with searching for a pattern in a suffix array:

```
find(Pattern P in SuffixArray A):
i = 0
lo = 0, hi = length(A)
for 0<=i<length(P):
Binary search for x,y
where P
```*=S[A[j]+i] for lo<=x<=j<y<=hi*

lo = x, hi = y

return {A[lo],A[lo+1],...,A[hi-1]}
```
and I am trying to get relocate it to java, but im slighty stuck. Not I can work out the simple stuff, and I have a binarysearch method, top example here (http://leepoint.net/notes-java/algorithms/searching/binarysearch.html)
If possible can someone walk me through the steps in the psuedo code in the for loop?
```

- 245 Views
- Tags: none (add)