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: 3 years ago

Preview 1 out of 5 pages

Buy Now

Instant download

We Accept:

Payment methods accepted on Scholarfriends (We Accept)
Preview image of Irvine Valley College - CS 41Source_Hash_Table.cpp document

Buy this document to get the full access instantly

Instant Download Access after purchase

Buy Now

Instant download

We Accept:

Payment methods accepted on Scholarfriends (We Accept)

Also available in bundle (1)

Click Below to Access Bundle(s)

Hash

Hash LAB

By Muchiri 4 years ago

$11

2  

Reviews( 0 )

$7.00

Buy Now

We Accept:

Payment methods accepted on Scholarfriends (We Accept)

Instant download

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

102
0

Document information


Connected school, study & course


About the document


Uploaded On

Apr 21, 2021

Number of pages

5

Written in

All

Seller


Profile illustration for Muchiri
Muchiri

Member since 4 years

209 Documents Sold

Reviews Received
19
5
1
1
6
Additional information

This document has been written for:

Uploaded

Apr 21, 2021

Downloads

 0

Views

 102

Document Keyword Tags

Recommended For You

Get more on Research Paper »

$7.00
What is Scholarfriends

Scholarfriends.com Online Platform by Browsegrades Inc. 651N South Broad St, Middletown DE. United States.

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 © Scholarfriends · High quality services·