quadratic_probing_hash_table.cpp File Reference

Storage mechanism using quadratic probing hash keys. More...

`#include <cmath>`
`#include <iostream>`
`#include <vector>`
Include dependency graph for quadratic_probing_hash_table.cpp:

## Classes

struct | quadratic_probing::Entry

## Namespaces

| quadratic_probing
| An implementation of hash table using quadratic probing algorithm.

## Typedefs

using | quadratic_probing::Entry = struct Entry

## Functions

bool | quadratic_probing::putProber (const Entry &entry, int key)
bool | quadratic_probing::searchingProber (const Entry &entry, int key)
void | quadratic_probing::add (int key)
size_t | quadratic_probing::hashFxn (int key)
int | quadratic_probing::quadraticProbe (int key, bool searching)
Entry | quadratic_probing::find (int key)
void | quadratic_probing::display ()
void | quadratic_probing::rehash ()
void | quadratic_probing::remove (int key)
void | quadratic_probing::addInfo (int key)
void | quadratic_probing::removalInfo (int key)
int | main ()

## Variables

int | quadratic_probing::notPresent
std::vector< Entry > | quadratic_probing::table
int | quadratic_probing::totalSize
int | quadratic_probing::tomb = -1
int | quadratic_probing::size
bool | quadratic_probing::rehashing

## Detailed Description

Storage mechanism using quadratic probing hash keys.

Author
  achance6
  Krishna Vedala

Note
  The implementation can be optimized by using OOP style.

## Function Documentation

## main()

int main | ( | void |  | ) |

Main function

Returns
  None

{
int cmd = 0, hash = 0, key = 0;
std::cout << "Enter the initial size of Hash Table. = ";
std::cin >> totalSize;
table = std::vector<Entry>(totalSize);
bool loop = true;
while (loop) {
std::cout << std::endl;
std::cout << "PLEASE CHOOSE -" << std::endl;
std::cout << "1. Add key. (Numeric only)" << std::endl;
std::cout << "2. Remove key." << std::endl;
std::cout << "3. Find key." << std::endl;
std::cout << "4. Generate Hash. (Numeric only)" << std::endl;
std::cout << "5. Display Hash table." << std::endl;
std::cout << "6. Exit." << std::endl;
std::cin >> cmd;
switch (cmd) {
case 1:
std::cout << "Enter key to add = ";
std::cin >> key;
quadratic_probing::addInfo(key);
break;
case 2:
std::cout << "Enter key to remove = ";
std::cin >> key;
quadratic_probing::removalInfo(key);
break;
case 3: {
std::cout << "Enter key to search = ";
std::cin >> key;
quadratic_probing::Entry entry =
quadratic_probing::table[quadratic_probing::quadraticProbe(
key, true)];
if (entry.key == quadratic_probing::notPresent) {
std::cout << "Key not present";
}
break;
}
case 4:
std::cout << "Enter element to generate hash = ";
std::cin >> key;
std::cout << "Hash of " << key
<< " is = " << quadratic_probing::hashFxn(key);
break;
case 5:
quadratic_probing::display();
break;
default:
loop = false;
break;
// delete[] table;
}
std::cout << std::endl;
}
return 0;
}
std::cin
std::cout
std::endl
T endl(T... args)
quadratic_probing::hashFxn
size_t hashFxn(int key)
Definition: quadratic_probing_hash_table.cpp:46
quadratic_probing::addInfo
void addInfo(int key)
Definition: quadratic_probing_hash_table.cpp:207
quadratic_probing::display
void display()
Definition: quadratic_probing_hash_table.cpp:142
quadratic_probing::removalInfo
void removalInfo(int key)
Definition: quadratic_probing_hash_table.cpp:222
quadratic_probing::quadraticProbe
int quadraticProbe(int key, bool searching)
Definition: quadratic_probing_hash_table.cpp:56
quadratic_probing::Entry
Definition: quadratic_probing_hash_table.cpp:37
quadratic_probing::Entry::key
int key
key value
Definition: quadratic_probing_hash_table.cpp:39
std::vector