Learn Computer Science programming - C# and C++ Algorithms

 
Hashtable in C++
A HashTable is a data structure for storing key/value pairs. It is an implementation of the DictionaryDataStructure. Hashtables are very efficient for the purpose of insertion and retrieval. They take O(1) time. A telephone book for example is a great example of a hashtable lookup implementation.
Paragraph.
Picture
Code
 
int y; int value;
char a[] = "TaXbccaT";
char *HashTable = new char[255];
ZeroMemory(HashTable, 255);
wcout << "The array is: " << a << endl;
for (int i=0; i < strlen(a); i++)
{
value = HashTable[(int)(a[i])] + 1;
HashTable[(int)(a[i])] = value;
wcout << endl << "ASCII: "  << (int)(a[i]) << "  char:  " << a[i] << " - Set Hashtable element: " << (int)(a[i]) << " with value " << value;
}
wcout << endl << endl << "Looping through Hashtable" << endl;
for (int j=0; j < strlen(a); j++)
{
if (HashTable[(int)(a[j])] == 1)
{
wcout << endl << "First Non Repeated Char = " << a[j] << " - Value = " << (int)(HashTable[(int)(a[j])]);
break;
}
}