Class HashTableSearch
Implements search using a hash table. Search algorithm is for finding a specific value in a list.
Inheritance
System.Object
HashTableSearch
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: AlgorithmsAndDataStructures.Algorithms.Search
Assembly: AlgorithmsAndDataStructures.dll
Syntax
public class HashTableSearch
Methods
| Improve this Doc View SourceConvertList2HashTable<T>(List<T>)
Creates a hash table for the given list. The keys are hashes of the elements in the list and th
Declaration
public static Dictionary<int, List<int>> ConvertList2HashTable<T>(List<T> list)
where T : IComparable<T>
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.List<T> | list | A list of elements. |
Returns
Type | Description |
---|---|
System.Collections.Generic.Dictionary<System.Int32, System.Collections.Generic.List<System.Int32>> | A hash table of elements hashes to their indexes in the list. |
Type Parameters
Name | Description |
---|---|
T | Type of the values stored in list. |
Search<T>(List<T>, T)
Implements search using a hash table.
Declaration
[Algorithm(AlgorithmType.Search, "HashTable")]
[SpaceComplexity("O(n)", false, InPlace = false)]
[TimeComplexity(Case.Best, "O(1)")]
[TimeComplexity(Case.Worst, "O(n)", When = "All the elements are mapped to the same key (for example due to lots of conflicts in the hashing method).")]
[TimeComplexity(Case.Average, "O(1)")]
public static List<int> Search<T>(List<T> list, T key)
where T : IComparable<T>
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.List<T> | list | A list of any comparable type. |
T | key | The value the method is searching for. |
Returns
Type | Description |
---|---|
System.Collections.Generic.List<System.Int32> | The list of all the indexes in the list that have |
Type Parameters
Name | Description |
---|---|
T |