Hi, for a project I have to read in a text file and using a "tree sort" i have to sort and count all of the words. I have the first part working but im not sure how to create this tree sort... all i know is that is similar to the quick sort.
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace ReadIn
{
class Program
{
static void Main(string[] args)
{
TextReader reader = new StreamReader("H:/Visual Studio 2005/Projects/ReadIn/ReadIn/bin/Debug/soccer.txt");//declares a streamreader to read text file
string line;//declares string where text file will function at
string words = "";//declares a blank string
int length;//declares an int to count word length
while ((line = reader.ReadLine()) != null)
{
int count = 0;
length = line.Length;
for (int n = 0; n < length; n++)
{
int test;
test = (int)line[n];
if ((test<=90)&(test>=65)|(test<=122)&(test>=97)|(test==37)|(test==45))
{
words += line[n];
count += 1;
}
else
{
if ((words != "") & (count>1))
{
Console.WriteLine(words.ToLower());
}
words = "";
}
}
if (words != "")
{
Console.WriteLine(words.ToLower());
}
words = "";
}
reader.Close();
Console.ReadKey();
}
}
class Tree
{
string word;
int count, left, right;
public Tree()
{
word = null;
count = 0;
}
public void initwords(Tree xBranch, string newWord)
{
Console.WriteLine("New Branch");
Console.WriteLine("Word: {0,-10) New: (1,-10)", xBranch.word, newWord);
if(words )??????????
{??????????/
???????????
}
}
}
}