Computer Science > Research Paper > Irvine Valley College - CS 41Source_Hash_Table.cpp (All)

Irvine Valley College - CS 41Source_Hash_Table.cpp

Document Content and Description Below

/* Create a hash table class/struct. Define an array that holds 27 elements. Define a function called Hash(int) -This function returns the modulo of that int by the size of the table (array). Def... ine an add function that takes an integer. -This function takes the integer, determines the hash of that number by calling the above hash function, then adds it to the table using linear probing for collision resolution. Define a function that looks up a value, it takes an integer, return -1 if the value is not in the table. Create a main that allows the user to add and lookup items in the table. */ #include <iostream> #include <string> using namespace std; // Declare the struct struct element { int info; element* next; }; // the size of the hash table followed by a linked list struct HashTable { private: const static int Tablesize = 27; // Define an array that holds 27 elements. element* ElementArea[Tablesize]; // elements in the hash table public: void initialization(); unsigned int Hash(int); void add(int); int search(int); }; void HashTable :: initialization() { for(int i = 0; i < Tablesize; i++) { ElementArea[i] = new element; ElementArea[i]->info = -999; // represents that the element area is empty ElementArea[i]->next = NULL; } } // hash function, returns an unsigned integer unsigned int HashTable:: Hash(int a) { return a % Tablesize; } void HashTable :: add(int inputvalue) [Show More]

Last updated: 1 year ago

Preview 1 out of 5 pages

Also available in bundle (1)

Hash

Hash LAB

By Muchiri 3 years ago

$11

2  

Reviews( 0 )

$7.00

Add to cart

Instant download

Can't find what you want? Try our AI powered Search

OR

GET ASSIGNMENT HELP
54
0

Document information


Connected school, study & course


About the document


Uploaded On

Apr 21, 2021

Number of pages

5

Written in

Seller


seller-icon
Muchiri

Member since 3 years

208 Documents Sold


Additional information

This document has been written for:

Uploaded

Apr 21, 2021

Downloads

 0

Views

 54

Document Keyword Tags

Recommended For You

What is Browsegrades

In Browsegrades, a student can earn by offering help to other student. Students can help other students with materials by upploading their notes and earn money.

We are here to help

We're available through e-mail, Twitter, Facebook, and live chat.
 FAQ
 Questions? Leave a message!

Follow us on
 Twitter

Copyright © Browsegrades · High quality services·