Greedy string tilting algorithm

tilting algorithm , visual basic 2005 , greedy string algorithm , vb.net Piedras Negras, Mexico
  • 8 years ago
    Hello everyone, I'm currently working on a greedy string tiling algorithm to find out matches between two strings, but there is something wrong with the string, they are not marked right so can you help me guys? Here is the code am trying: Sub GST2(ByVal str1 As Array, ByVal str2 As Array) Dim a, b, j, cnt, jj, max_a, max_b As Integer ' Do While maxmatch > 3 cnt = 0 maxmatch = 2 For a = 0 To str1.Length - 1 'new index to put a new tile in cnt += 1 maxmatch = 2 max_a = 0 max_b = 0 jj = 1 For b = 0 To str2.Length - 1 j = 0 'same chars and not marked While str1(a + j) = str2(b + j) And str1(a + j) <> "" And str2(b + j) <> "" If b + j <= str2.Length - 1 Or a + j <= str1.Length - 1 Then j += 1 Else j += 1 Exit While End If End While 'we got a larger match If j > maxmatch Then match(a, b, j, cnt) max_a = a max_b = b maxmatch = j jj = j Else End If Next mark(max_a, max_b, jj, str1, str2) Next printArray() Dim i As Integer For i = 0 To str1.Length - 1 TextBox6.Text = TextBox6.Text & vbCrLf & ar(i) Next For i = 0 To str2.Length - 1 TextBox7.Text = TextBox7.Text & vbCrLf & ar2(i) Next End Sub Sub match(ByVal a As Integer, ByVal b As Integer, ByVal c As Integer, ByVal cnt As Integer) MyArray(cnt, 0) = a MyArray(cnt, 1) = b MyArray(cnt, 2) = c End Sub Sub mark(ByVal a As Integer, ByVal b As Integer, ByVal j As Integer, ByRef str1 As Array, ByRef str2 As Array) Dim i As Integer For i = a To i + j - 1 str1(i) = "" Next For i = b To i + j - 1 str2(i) = "" Next End Sub Sub printArray() Dim output As String = "" Dim i, j As Integer For i = 0 To MyArray.GetUpperBound(0) For j = 0 To MyArray.GetUpperBound(1) output += MyArray(i, j) & " " Next output &= vbCrLf Next TextBox5.Text = output End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click GST2(ar, ar2) End Sub End Class

Post a reply

No one has replied yet! Why not be the first?

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Brevity is the soul of wit” - Shakespeare