/// <summary> /// This method wil take in 2 lists that will store the preordered binary trees. /// Next the values at each tree are hashed into the hash table. /// The first for loop will add the first list into the hash table /// The second list we will create a index for the hash table /// We will do a check using the contains method to see if both values that were hashed are contained in the table /// If they are contained we add to the new final list, otherwise add to table /// </summary> /// <param name="storedTreeValues"></param> /// <param name="storedTreeValues2"></param> /// <param name="tree1"></param> /// <param name="tree2"></param> /// <returns></returns> public static List <int> TreeIntersection(List <int> storedTreeValues, List <int> storedTreeValues2, BinaryTree tree1, BinaryTree tree2) { // Setting up tree 1 iteration to final list HashTableSetup table = new HashTableSetup(1024); tree1.PreOrder(tree1.Top, storedTreeValues); tree2.PreOrder(tree2.Top, storedTreeValues2); List <int> finalList = new List <int>(); int index; for (int i = 0; i < storedTreeValues.Count; i++) { table.Add(storedTreeValues[i].ToString(), storedTreeValues[i].ToString()); for (int j = 0; j < storedTreeValues2.Count; j++) { index = table.Hash(storedTreeValues2[j].ToString()); if (table.Contains(storedTreeValues2[j].ToString(), index) && table.Contains(storedTreeValues[i].ToString(), index)) { finalList.Add(storedTreeValues2[j]); } else { table.Add(storedTreeValues2[j].ToString(), index); } } } return(finalList); }
public void CheckContainsValue(Object key, int value) { HashTableSetup table = new HashTableSetup(1024); table.Add(key, value); Object nodeValue = table.Bucket[value].Find(key); Assert.True(table.Contains(key, value)); }
public void CheckNullForNoValue(Object key, int value) { HashTableSetup table = new HashTableSetup(1024); table.Add(key, value); Object nodeValue = table.Bucket[value].Find("dan"); Assert.Null(nodeValue); }/// <summary>
public void Add(Object key, int value) { HashTableSetup table = new HashTableSetup(1024); table.Add(key, value); Object nodeValue = table.Bucket[value].Find(key); Assert.Equal(value, nodeValue); }
public void HandleCollision() { HashTableSetup table = new HashTableSetup(1024); table.Add("below", 72); table.Add("elbow", 72); Assert.True(table.Contains("below", 72)); Assert.True(table.Contains("elbow", 72)); }
public void RetrievCollisionValues() { HashTableSetup table = new HashTableSetup(1024); table.Add("below", 72); table.Add("elbow", 72); Object FindValue1 = table.Bucket[72].Find("below"); Object FindValue2 = table.Bucket[72].Find("elbow"); Assert.True(table.Contains("below", 72)); Assert.True(table.Contains("elbow", 72)); }
public static Array LeftJoin(HashTableSetup table1, HashTableSetup table2) { List <Array> final = new List <Array>(); List <string> values = new List <string>(); values.Add(key1); return; }
static void Main(string[] args) { HashTableSetup table1 = new HashTableSetup(1024); HashTableSetup table2 = new HashTableSetup(1024); List <string> Keys = new List <string>(); table1.Add("fond", "enamored"); table1.Add("wrath", "anger"); table1.Add("diligent", "employed"); table1.Add("outift", "garb"); table1.Add("guide", "usher"); table2.Add("fond", "averse"); table2.Add("wrath", "delight"); table2.Add("diligent", "idle"); table2.Add("guide", "follow"); table2.Add("flow", "jam"); }
/// <summary> /// This function will first split our word by all delimeters specified. /// We will then create a hash table and hash each word that is split. /// If the word is contained withing the linked list it will return that value, if not /// we will add it to the linked list /// </summary> /// <param name="repeatedWord"></param> /// <returns></returns> public static string RepeatedWords(string repeatedWord) { string[] splitInput = repeatedWord.Split(' ', ',', ':', ';', '.'); HashTableSetup table = new HashTableSetup(1024); int index; for (int i = 0; i < splitInput.Length; i++) { index = table.Hash(splitInput[i].ToLower()); if (table.Contains(splitInput[i].ToLower(), index)) { return(splitInput[i].ToLower()); } else { table.Add(splitInput[i].ToLower(), index); } } return(null); }
public void AddingKeyAndValueToHashTable(Object key, int indx) { HashTableSetup table = new HashTableSetup(1024); Assert.Equal(indx, table.Hash(key)); }