示例#1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Welcome to Hash Table Program");
            MyMapNode <string, string> hash = new MyMapNode <string, string>(5);

            hash.Add("0", "Paranoids");
            hash.Add("1", "are");
            hash.Add("2", "not");
            hash.Add("3", "paranoids");
            hash.Add("4", "beacuse");
            hash.Add("5", "they");
            hash.Add("6", "are");
            hash.Add("7", "paranoid");
            hash.Add("8", "but");
            hash.Add("9", "because");
            hash.Add("10", "they");
            hash.Add("11", "keep");
            hash.Add("12", "putting");
            hash.Add("13", "themselves");
            hash.Add("14", "deliberately");
            hash.Add("15", "into");
            hash.Add("16", "paranoid");
            hash.Add("17", "avoidable");
            hash.Add("18", "situations");
            hash.GetFrequency("avoidable");
            hash.RemoveValue("avoidable");
            hash.GetFrequency("avoidable");
        }
示例#2
0
        static void Main(string[] args)
        {
            int frequency;

            Console.WriteLine("Welcome To Hash Table Program");
            MyMapNode <string, int> hash = new MyMapNode <string, int>(5);
            string paragraph             = "Paranoids are not paranoid because they are paranoid but because they keep putting themselves deliberately into paranoid avoidable situations";

            string[] words = paragraph.Split(" ");
            for (int i = 0; i < words.Length; i++)
            {
                if (hash.GetFrequency(words[i]) == default)
                {
                    frequency = 1;
                    hash.Add(words[i], frequency);
                }
                else
                {
                    frequency = hash.GetFrequency(words[i]);
                    hash.SetFrequency(words[i], ++frequency);
                }
            }

            Console.WriteLine("Frequency :" + hash.GetFrequency("avoidable"));
            hash.Remove("avoidable");
            Console.WriteLine("Frequency after removing :" + hash.GetFrequency("avoidable"));
        }
示例#3
0
        static void Main(string[] args)
        {
            Console.WriteLine("Welcome to the Hash Table Data structure practice problem.");
            MyMapNode <string, string> hash = new MyMapNode <string, string>(5);

            hash.Add("0", "To");
            hash.Add("1", "be");
            hash.Add("2", "or");
            hash.Add("3", "not");
            hash.Add("4", "to");
            hash.Add("5", "be");
            hash.GetFrequency("be");

            //UC2 frequency of word in a paragraph
            MyMapNode <string, string> hash2 = new MyMapNode <string, string>(19);

            hash2.Add("0", "Paranoid");
            hash2.Add("1", "are");
            hash2.Add("2", "not");
            hash2.Add("3", "paranoid");
            hash2.Add("4", "beacuse");
            hash2.Add("5", "they");
            hash2.Add("6", "are");
            hash2.Add("7", "paranoid");
            hash2.Add("8", "but");
            hash2.Add("9", "because");
            hash2.Add("10", "they");
            hash2.Add("11", "keep");
            hash2.Add("12", "putting");
            hash2.Add("13", "themselves");
            hash2.Add("14", "deliberately");
            hash2.Add("15", "into");
            hash2.Add("16", "paranoid");
            hash2.Add("17", "avoidable");
            hash2.Add("18", "situations");
            hash2.GetFrequency("paranoid");
            hash2.Remove("17");
            hash2.GetFrequency("avoidable");
            Console.ReadKey();
        }