public static void Main(string[] args) { Console.WriteLine("Welcome to Hash Table implementation"); 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"); string hash5 = hash.Get("4"); Console.WriteLine("5th index value:" + hash5); string paragraph = "Paranoids are not paranoid because they are paranoid but because they keep putting themselves deliberately into paranoid avoidable situations"; ///Split converts paragraph into array of sub strings. string[] para = paragraph.Split(" "); ///Creating reference of MyMapNode. MyMapNode <int, string> hash1 = new MyMapNode <int, string>(para.Length); int key = 0; ///foreach iterates on paragraph and adds key and value to hash. foreach (string word in para) { hash1.Add(key, word); key++; } Console.WriteLine("\nFrequency :" + hash1.GetFrequency("paranoid")); hash1.RemoveValue("avoidable"); Console.WriteLine("Frequency :" + hash.GetFrequency("avoidable")); }
public void RemoveWord(string wordToRemove) { MyMapNode <string, int> map = myMap; map.RemoveValue(wordToRemove); Console.WriteLine($"Frequency of \"{wordToRemove}\" after removal is {map.GetValue(wordToRemove)} "); }
static void Main(string[] args) { Console.WriteLine("Welcome to hashtable demo"); 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"); Console.ReadKey(); }
static void Main(string[] args) { Console.WriteLine("Hash table demo"); 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"); string checkFreq = "be"; int freq = hash.GetFrequency(checkFreq); Console.ReadKey(); Console.WriteLine("Hash table demo"); MyMapNode <string, string> hash = new MyMapNode <string, string>(5); string para = "Paranoids are not paranoid because they are paranoid but because they keep putting themselves deliberately into paranoid avoidable situations"; string[] paraWords = para.Split(' '); int pLength = paraWords.Length; for (int i = 0; i < pLength; i++) { hash.Add(Convert.ToString(i), paraWords[i]); } foreach (string word in paraWords) { hash.GetFrequency(word); } Console.ReadKey(); Console.WriteLine("Hash table demo"); MyMapNode <string, string> hash = new MyMapNode <string, string>(5); string para = "Paranoids are not paranoid because they are paranoid but because they keep putting themselves deliberately into paranoid avoidable situations"; string[] paraWords = para.Split(' '); int pLength = paraWords.Length; for (int i = 0; i < pLength; i++) { hash.Add(Convert.ToString(i), paraWords[i]); } Console.WriteLine("Frequency of 'avoidable' before removal is :" + hash.GetFrequency("avoidable")); hash.RemoveValue("avoidable"); Console.WriteLine("Frequency of 'avoidable' after removal is :" + hash.GetFrequency("avoidable")); Console.ReadKey(); Console.WriteLine("Hello!! Welcome to Binary Search Tree"); BST <int> bst = new BST <int>(); bst.Insert(56); bst.Insert(30); bst.Insert(70); bst.DisplayBST(bst.root); int[] arr = { 56, 30, 70, 22, 60, 40, 95, 16, 63, 67, 4, 11, 65 }; for (int i = 0; i < arr.Length; i++) { bst.Insert(arr[i]); } bst.DisplayBST(bst.root); Console.WriteLine("\n\nSize of BST: " + bst.Size(bst.root)); bst.Search(60); bst.Search(20); }