Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please write the codes with their given name ( void insertIntoHashTable(int input); void insertIntoHashTable(const char* input); bool searchInHashTable(int input); bool searchInHashTable(const char* input); ) in

please write the codes with their given name (

void insertIntoHashTable(int input); void insertIntoHashTable(const char* input); bool searchInHashTable(int input); bool searchInHashTable(const char* input);

) in C++

image text in transcribedimage text in transcribedimage text in transcribed

Aim: To learn and implement basics of hashing and to improve your understanding of working within constraints (i.e. being have to use the asked function types, learning from the comments...) What is hashing? Hashing is the process of converting a given key into another value. It is used for a fast-access data storage in implementations called Hash Tables". Let's assume that you have values 5, 9, 23, 4, 78, 8, 42, 7, 1, 271, 251, 420 in a linked list and you want to find 251. Traditionally, you iterate from the beginning and only access 251 in your 11* iteration. However, a hash table with key value of 10 stores data like this: 0: 420 1: 1, 271, 251 2: 42 3: 23 4: 4 5: 5 6: 7: 7 8: 78, 8 9: 9 Simply, takes modulus of these variables and puts them accordingly. Therefore, if you look up for 251, you simply 251 % 10 and get 1 and only check ls to find 251 for a much higher search speed. This is a simple hash table application. Another implementation of hashing is for validating data within different data types. Such as encryption and cyrptographic operations. There will be some future details given after your assignment explanation. Q (100pts): Write a hash implementation for both integer and up-to-4-digit string type inputs into the main with the prototypes given in the source file main.cpp. Also, you should use linked list implementation given to you previously this semester: IntsLlist. The functions you are asked to build are: void insertInto Hash Table(int input); void insertinto HashTable(const char* input); bool searchInHashTable(int input); bool searchinHash Table(const char* input); Important: Your work should compile & run along with the example main file provided to you. You can compile multiple cpp files using: g++ main.cpp intsLlist.cpp Also, make no changes to the given main class except corresponding areas for your functions. You can use existing source and header files intSLList.cpp and intSLList.h which are totally complete. You may also want to use comments efficiently, especially if your assignment isn't 100% done for helping us to understand your studies better. So, if you realized, you are being asked to implement a hash table that can store both integer and up-to-4-digit string values. Yet, your list implementation that should hold values only store integers. How are you supposed to store strings within integers, right? Maybe stoi, but then you cannot differentiate ASD" from "ADS" since the totals would be the same. Then how? With hashing. You can hash the string's character values individually into an integer one by one. For example, ASCII value of character A is 65 and B is 66. If you were to store ABB, you can simply store it as 656666" or "666665" within an integer. And if you unhash it you get ABB. That's another use of hashing for a very simple cryptographic implementation. So, here is an execution snippet for helping you to visualize: insertintoHashTable(1); insertintoHashTable(11): insertintoHashTable(6); insertintoHashTable(121); insert IntoHashTable( "AAA"); Insert IntoHashTable("Y"); InsertintoHashTable("30E"); printHashTable(); cout ? @ABCDEFGHIJKLMNO PQRSTUVW X Y Z ASCII val. of 'A' is: 65 value 65 equals to character: A ugurn@ubuntu:-/Desktop/cse211as95$

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Conceptual Database Design An Entity Relationship Approach

Authors: Carol Batini, Stefano Ceri, Shamkant B. Navathe

1st Edition

0805302441, 978-0805302448

More Books

Students also viewed these Databases questions