notes117

notes117 - Midterm - Wednesday March 20 - WTHR 200 - 7 - 9...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
-No class -PSOs to answer questions -Review on website Implementing a hash table HashTable.h struct HashNode { int _key; char *_element; HashNode *_next; } const int MaxHashSize = 1039; class HashTable { HashNode *hashTable[MaxHashSize]l; public: HashTable(); void insertHash(int key, char *element); char *lookup(int key); }; HashTable.cc HashTable::HashTable(){ for (int i = 0; i<MaxHashSize; i++){ _hashTable[i] = NULL; } } void HashTable::insertHash(int key, char *element){ HashNode *node = new HashNode(); assert(node!=NULL); node->_key = key; node->_element = element; int index = (key % MaxHashSize); //add to hashtable. Insert at beginning of list node->_next = hashTable[index]; hashTable[index] = node; } char * HashTable::lookup(int key) { int index = key % MaxHashSize; HashNode *node = hashTable[index]; node = node->_next; } if (node == NULL) return NULL; char *val = node->_element; return val; } (2,4) Trees cont. . Insertion Review
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 7

notes117 - Midterm - Wednesday March 20 - WTHR 200 - 7 - 9...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online