0

I am finding longest substring in text T, such that it is a prefix of string S. I have made algorithm using suffix tree which provides less complex solution, but since Matlab doesn't use pointers or any other reference, I am stuck at the implementation.

Could somebody please suggest some solution or some alternate way to this problem, possible in Matlab.

Mangat Rai Modi
  • 5,397
  • 8
  • 45
  • 75

1 Answers1

1

Here are a few suggestions for using "pointers" in Matlab:

  • You can simply use cell array indexes as pointers, to reference cell array elements. This is probably the simplest approach.
  • You can use a Handle Class for creating classes which you can hold references to. A little more involved but very nice from a software engineering point of view.
  • As less Matlaby solution, you could write the algorithm in C and use mex to interface between Matlab and your algorithm.
devrobf
  • 6,973
  • 2
  • 32
  • 46
  • mex interface? I will google that. Because I think implementing a tree will be much simpler in C. By the way, I will search on other suggestions also. Thanks for help – Mangat Rai Modi Mar 20 '13 at 10:43
  • Any idea if we could use some reference object in Matlab structure field value? – Mangat Rai Modi Mar 20 '13 at 11:01
  • Well, a struct field value can only store the same things as any other Matlab variable, so one of the first two options - a cell array index or a handle reference. – devrobf Mar 20 '13 at 13:54