Francisca Fraser

Francisca Fraser

  • NA
  • 12
  • 1.2k

Help needed urgently: Performing searches using regex

May 5 2018 5:57 AM
Hello
 Can someone provide me with the format of how to do searches from a binary search tree of words using regex.
 
I created a program that stores the the words from a text file in a binary search tree. Now I have to be able to do various types of searches to return the words and the frequency of occurences.
 
e.g if I search for the word "deer"; or words that starts with "pr" or words that ends with "ed" etc . the program must be able to return the word/s and the number of times they occur.
 
I've tried following examples online but everything I"ve tried comes up with errors.
 
I am really new to this and it's posing a challenge for me.
 please help
Thanks You 
 
Here is the source code 
 
Using System;
using System.IO;
using System.Linq;
namespace binarysearchtree
{
class BinarySearchTree
{
static void Main(string[] args)
{
BinaryTree BT = new BinaryTree();
string line; // will be used to read the file, one line at a time
int count;
string[] words;
try
{
count = 1;
StreamReader reader = new StreamReader("testfile.txt");//create input stream
line = reader.ReadLine();//get the next line
while (line != null)
{
words = line.Split(' ');
for (int i = 0; i < words.Length; i++)
BT.Insert(words[i], count);
line = reader.ReadLine();
}
reader.Close();
}
catch (IOException e)
{
Console.WriteLine("" + e.ToString());
}
BT.Display();
Console.ReadLine();