Question: VIsual Studio Question: How can i enter information in the white box (textbox1), have the user press Rabin Karp (ProgramTest.cs & Program.cs) and have the
VIsual Studio Question: How can i enter information in the white box (textbox1), have the user press Rabin Karp (ProgramTest.cs & Program.cs) and have the results generated in a new window. THe results will display the pattern that will be entered into the white box and the Rabin Karp will be an algorithm to search the pattern in the generated sequence. (see below for code for Rabin Karp).
private void textBox1_TextChanged(object sender, EventArgs e) {
}

Program.cs
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;
namespace RabinKarp { public class Program { string s; string pattern; int Q = 100007;
public const int d = 256;
public Program(string name) {
}
public void InputPattern() { Console.WriteLine("Enter the pattern you want to search: "); pattern = (Console.ReadLine()).ToUpper(); //read user input
}
public void RandomGenerator() { Random geneSequence = new Random(); // The random number sequence
for (int i = 0; i
switch (x) { case 1: s = s + 'C'; break;
case 2: s = s + 'T'; break;
case 3: s = s + 'A'; break;
case 4: s = s + 'G'; break; }
}
Console.WriteLine(s); //display results of string }
public void Search() // s is string sequence, pattern is what is inputted from user {
//Rabin karp algorithm is executed here int n; n = s.Length;
int m; m = pattern.Length;
int i; int j;
int p = 0; int h = 1; int t = 0;
for (i = 0; i
}
public void DisplayTime() { var watch = System.Diagnostics.Stopwatch.StartNew(); // the code that you want to measure comes here watch.Stop(); var elapsedMs = watch.ElapsedMilliseconds;
Console.WriteLine("Time processed: {0}ms", watch.ElapsedMilliseconds); }
}
}
ProgramTest.cs
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;
namespace RabinKarp { public class ProgramTest { public static void Main(string[] args) { Program myProgram = new Program("Thank you for running the " + "Rabin Karp Algorithm");
myProgram.InputPattern(); //read in the inputted pattern from user
myProgram.RandomGenerator(); //run the random generator program
//i am trying to run this function so that it can run the string and pattern myProgram.Search();
myProgram.DisplayTime();
Console.Read(); } } }
StartT D Class1.cs Form1.cs Form1.cs [Design] ? Form 1 Brute Force Rabin Karp Boyer Moore Knuth Morris Pratt Heuristic Algorithm
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
