Iurii Tatishchev 3d112946f5
9.12 Lab: Hashing - Linear Probe (insert, search)
Hash Function: Add the ASCII values of all characters in the key string and return the reminder obtained when divided by the size of the table.

Example: If key = "Bob", and size = 53, we get (66 + 111 + 98) % 53 => 275 % 53 => 10.

Collision Resolution Method: Linear Probe.

The assignment consists of the following classes/files:

- main.cpp (incomplete)
- Student.h (given)
- HashNode.h (given)
- HashTable.h (given)
- HashTable.cpp (incomplete)

Read and understand the given code then write two functions:

- insert hash
- search hash
2024-05-11 15:43:39 -07:00

35 lines
555 B
C++

// Specification file for the Student class
#ifndef STUDENT_H
#define STUDENT_H
using std::string;
class Student {
private:
double gpa;
string name;
public:
Student() {
name = "";
gpa = -1;
} // Constructor
Student(string n, double g) {
name = n;
gpa = g;
} // Overloaded Constructor
// Setters and getters
void setName(string n) { name = n; }
void setGpa(double g) { gpa = g; }
string getName() const { return name; }
double getGpa() const { return gpa; }
};
#endif