SlideShare a Scribd company logo
1 of 30
Download to read offline
C++ project
Machine Problem 7 - Hashing
Write a program to do the following:
loads username/password sets from the file password.txt and insert them into the hash table until
the end of file is reached on password.txt. The password.txt file will look something like this
with one username/password set per line.
mary changeMe!
The program will then present a login prompt, read one username, present a password prompt,
and after looking up the username's password in the hash table, will print either "Authentication
successful" or "Authentication failure".
The above step will be repeated until the end of the input data (EOF) is reached on the console
input stream (cin). The EOF character on the PC's is the CTRL Z character.
To convert from a string to an integer, we can add the ascii value of each character together. For
instance, Mary's conversion from string to integer might look something like this:
109('m') + 97('a') + 114('r') + 121('y')=441
We've converted the string to an integer, but we still need to convert the integer to an index. For
an array of 10 elements we can divide by 10 and use the remainder as an index. Combining these
two hash functions, we will get Mary's index to be: 441 % 10 = 1
Your primary tasks for this homework are to edit the login.cpp to replace the comments with
lines so that it does the following:
Insert passwords into the Hash Table.
Retrieve one user's Password structure from the Hash Table.
Compare retrieved user password to input password and print "Authentication failure" or
"Authentication successful."
//--------------------------------------------------------------------
//
// listlnk.h
//
//--------------------------------------------------------------------
#pragma warning( disable : 4290 )
#include
#include
#include
#include
#include
#include
#include
using namespace std;
template < class T > // Forward declaration of the List class
class List;
template < class T >
class ListNode // Facilitator class for the List class
{
private:
ListNode(const T &nodeData, ListNode *nextPtr);
T dataItem; // List data item
ListNode *next; // Pointer to the next list node
friend class List;
};
//--------------------------------------------------------------------
template < class T >
class List
{
public:
List(int ignored = 0);
~List();
void insert(const T &newData) throw (bad_alloc); // Insert after cursor
void remove() throw (logic_error); // Remove data item
void replace(const T &newData) throw (logic_error); // Replace data item
void clear();
bool isEmpty() const;
bool isFull() const;
// List iteration operations
void gotoBeginning() throw (logic_error);
void gotoEnd() throw (logic_error);
bool gotoNext();
bool gotoPrior();
T getCursor() const throw (logic_error); // Return item
void showStructure() const;
void moveToBeginning() throw (logic_error); // Move to beginning
void insertBefore(const T &newElement) throw (bad_alloc); // Insert before cursor
private:
ListNode *head, // Pointer to the beginning of the list
*cursor; // Cursor pointer
};
//--------------------------------------------------------------------
//
// listlnk.cpp
//
//--------------------------------------------------------------------
template < class T >
ListNode::ListNode(const T &nodeDataItem, ListNode *nextPtr) : dataItem(nodeDataItem),
next(nextPtr)
{}
//--------------------------------------------------------------------
template < class T >
List::List(int ignored) : head(0), cursor(0)
{}
//--------------------------------------------------------------------
template < class T >
List:: ~List()
{
clear();
}
//--------------------------------------------------------------------
template < class T >
void List::insert(const T &newDataItem) throw (bad_alloc)
{
if (head == 0) // Empty list
{
head = new ListNode(newDataItem, 0);
cursor = head;
}
else // After cursor
{
cursor->next = new ListNode(newDataItem, cursor->next);
cursor = cursor->next;
}
}
//--------------------------------------------------------------------
template < class T >
void List::remove() throw (logic_error)
{
ListNode *p, // Pointer to removed node
*q; // Pointer to prior node
// Requires that the list is not empty
if (head == 0)
throw logic_error("list is empty");
if (cursor == head) // Remove first item
{
p = head;
head = head->next;
cursor = head;
}
else if (cursor->next != 0) // Remove middle item
{
p = cursor->next;
cursor->dataItem = p->dataItem;
cursor->next = p->next;
}
else // Remove last item
{
p = cursor;
for (q = head; q->next != cursor; q = q->next)
;
q->next = 0;
cursor = head;
}
delete p;
}
//--------------------------------------------------------------------
template < class T >
void List::replace(const T &newDataItem) throw (logic_error)
{
if (head == 0)
throw logic_error("list is empty");
cursor->dataItem = newDataItem;
}
//--------------------------------------------------------------------
template < class T >
void List::clear()
{
ListNode *p, // Points to successive nodes
*nextP; // Points to next node
p = head;
while (p != 0)
{
nextP = p->next;
delete p;
p = nextP;
}
head = 0;
cursor = 0;
}
//--------------------------------------------------------------------
template < class T >
bool List::isEmpty() const
{
return (head == 0);
}
//--------------------------------------------------------------------
template < class T >
bool List::isFull() const
{
T testDataItem;
ListNode *p;
try
{
p = new ListNode(testDataItem, 0);
}
catch (bad_alloc)
{
return true;
}
delete p;
return false;
}
//--------------------------------------------------------------------
template < class T >
void List::gotoBeginning() throw (logic_error)
{
if (head != 0)
cursor = head;
else
throw logic_error("list is empty");
}
//--------------------------------------------------------------------
template < class T >
void List::gotoEnd() throw (logic_error)
{
if (head != 0)
for (; cursor->next != 0; cursor = cursor->next)
;
else
throw logic_error("list is empty");
}
//--------------------------------------------------------------------
template < class T >
bool List::gotoNext()
{
bool result; // Result returned
if (cursor->next != 0)
{
cursor = cursor->next;
result = true;
}
else
result = false;
return result;
}
//--------------------------------------------------------------------
template < class T >
bool List::gotoPrior()
// If the cursor is not at the beginning of a list, then moves the
// cursor to the preceeding item in the list and returns 1.
// Otherwise, returns 0.
{
ListNode *p; // Pointer to prior node
int result; // Result returned
if (cursor != head)
{
for (p = head; p->next != cursor; p = p->next)
;
cursor = p;
result = true;
}
else
result = false;
return result;
}
//--------------------------------------------------------------------
template < class T >
T List::getCursor() const throw (logic_error)
{
if (head == 0)
throw logic_error("list is empty");
return cursor->dataItem;
}
//--------------------------------------------------------------------
template < class T >
void List::showStructure() const
{
ListNode *p; // Iterates through the list
if (head == 0)
cout << "Empty list" << endl;
else
{
for (p = head; p != 0; p = p->next)
if (p == cursor)
cout << "[" << p->dataItem << "] ";
else
cout << p->dataItem << " ";
cout << endl;
}
}
//--------------------------------------------------------------------
template < class T >
void List::moveToBeginning() throw (logic_error)
// Removes the item marked by the cursor from a list and
// reinserts it at the beginning of the list. Moves the cursor to the
// beginning of the list.
{
ListNode *p; // Pointer to prior node
// Requires that the list is not empty
if (head == 0)
throw logic_error("list is empty");
if (cursor != head)
{
for (p = head; p->next != cursor; p = p->next)
;
p->next = cursor->next;
cursor->next = head;
head = cursor;
}
}
//--------------------------------------------------------------------
template < class T >
void List::insertBefore(const T &newDataItem)
throw (bad_alloc)
// Inserts newDataItem before the cursor. If the list is empty, then
// newDataItem is inserted as the first (and only) item in the list.
// In either case, moves the cursor to newDataItem.
{
if (head == 0) // Empty list
{
head = new ListNode(newDataItem, 0);
cursor = head;
}
else // Before cursor
{
cursor->next = new ListNode(cursor->dataItem, cursor->next);
cursor->dataItem = newDataItem;
}
}
//--------------------------------------------------------------------
// hashtbl.h
//--------------------------------------------------------------------
template < class T, class KF >
class HashTbl
{
public:
HashTbl(int initTableSize);
~HashTbl();
void insert(const T &newDataItem) throw (bad_alloc);
bool remove(KF searchKey);
bool retrieve(KF searchKey, T &dataItem);
void clear();
bool isEmpty() const;
bool isFull() const;
void showStructure() const;
private:
int tableSize;
List *dataTable;
};
//--------------------------------------------------------------------
// hashtbl.cpp
//--------------------------------------------------------------------
template < class T, class KF >
HashTbl::HashTbl(int initTableSize) : tableSize(initTableSize)
{
dataTable = new List[tableSize];
}
template < class T, class KF >
HashTbl:: ~HashTbl()
{
delete[] dataTable;
}
template < class T, class KF >
void HashTbl::insert(const T &newDataItem) throw (bad_alloc)
{
int index = 0;
index = newDataItem.hash(newDataItem.getKey()) % tableSize;
if (dataTable[index].isEmpty())
dataTable[index].insert(newDataItem);
else
{
dataTable[index].gotoBeginning();
do
{
if (dataTable[index].getCursor().getKey() == newDataItem.getKey())
{
dataTable[index].replace(newDataItem);
return;
}
} while (dataTable[index].gotoNext());
dataTable[index].insert(newDataItem);
}
}
template < class T, class KF >
bool HashTbl::remove(KF searchKey)
{
T temp;
int index = 0;
index = temp.hash(searchKey) % tableSize;
if (dataTable[index].isEmpty())
return false;
dataTable[index].gotoBeginning();
do
{
if (dataTable[index].getCursor().getKey() == searchKey)
{
dataTable[index].remove();
return true;
}
} while (dataTable[index].gotoNext());
return false;
}
template < class T, class KF >
bool HashTbl::retrieve(KF searchKey, T &dataItem)
{
// apply two hash functions:
// convert string (searchkey) to integer
// and use the remainder method (% tableSize) to get the index
int index = 0;
index = dataItem.hash(searchKey) % tableSize;
if (dataTable[index].isEmpty())
return false;
dataTable[index].gotoBeginning();
do
{
if (dataTable[index].getCursor().getKey() == searchKey)
{
dataItem = dataTable[index].getCursor();
return true;
}
} while (dataTable[index].gotoNext());
return false;
}
template < class T, class KF >
void HashTbl::clear()
{
for (int i = 0; i
bool HashTbl::isEmpty() const
{
for (int i = 0; i
bool HashTbl::isFull() const
{
for (int i = 0; i
void HashTbl::showStructure() const
{
cout << "The Hash Table has the following entries" << endl;
for (int i = 0; i passwords(10);
Password tempPass;
string name; // user-supplied name
string pass; // user-supplied password
//bool userFound; // is user in table?
//*********************************************************
// Step 1: Read in the password file
//*********************************************************
ifstream passFile("password.txt");
if (!passFile)
{
cout << "Unable to open 'password.txt'!" << endl;
exit(0);
}
passFile >> tempPass.username;
while (!passFile.eof() && !passwords.isFull())
{
//**add line here to insert passwords into the HashTbl
passFile >> tempPass.password;
}
cout << "Printing the hash table:..." << endl;
//**add line here to show (print) the HashTbl
//*********************************************************
// Step 2: Prompt for a Login and Password and check if valid
//*********************************************************
cout << "Login: ";
while (cin >> name) // to quit, type CTRL Z in Visual C++
{
//**add line here to retrieve user from HashTbl
cout << "Password: ";
cin >> pass;
//**add lines here to compare retrieved user password to
//**input password and print "Authentication failure"
//**or "Authentication successful"
cout << "Login: ";
}
cout << endl;
}
Please upload the following:
The class .cpp file
The main program
The class .h file
Output File
Solution
#include
#include
#include
#include
#include
#include
#include
using namespace std;
template < class T > // Forward declaration of the List class
class List;
template < class T >
class ListNode // Facilitator class for the List class
{
private:
ListNode(const T &nodeData, ListNode *nextPtr);
T dataItem; // List data item
ListNode *next; // Pointer to the next list node
friend class List;
};
//--------------------------------------------------------------------
template < class T >
class List
{
public:
List(int ignored = 0);
~List();
void insert(const T &newData) throw (bad_alloc); // Insert after cursor
void remove() throw (logic_error); // Remove data item
void replace(const T &newData) throw (logic_error); // Replace data item
void clear();
bool isEmpty() const;
bool isFull() const;
// List iteration operations
void gotoBeginning() throw (logic_error);
void gotoEnd() throw (logic_error);
bool gotoNext();
bool gotoPrior();
T getCursor() const throw (logic_error); // Return item
void showStructure() const;
void moveToBeginning() throw (logic_error); // Move to beginning
void insertBefore(const T &newElement) throw (bad_alloc); // Insert before cursor
private:
ListNode *head, // Pointer to the beginning of the list
*cursor; // Cursor pointer
};
//--------------------------------------------------------------------
//
// listlnk.cpp
//
//--------------------------------------------------------------------
template < class T >
ListNode::ListNode(const T &nodeDataItem, ListNode *nextPtr) : dataItem(nodeDataItem),
next(nextPtr)
{}
//--------------------------------------------------------------------
template < class T >
List::List(int ignored) : head(0), cursor(0)
{}
//--------------------------------------------------------------------
template < class T >
List:: ~List()
{
clear();
}
//--------------------------------------------------------------------
template < class T >
void List::insert(const T &newDataItem) throw (bad_alloc)
{
if (head == 0) // Empty list
{
head = new ListNode(newDataItem, 0);
cursor = head;
}
else // After cursor
{
cursor->next = new ListNode(newDataItem, cursor->next);
cursor = cursor->next;
}
}
//--------------------------------------------------------------------
template < class T >
void List::remove() throw (logic_error)
{
ListNode *p, // Pointer to removed node
*q; // Pointer to prior node
// Requires that the list is not empty
if (head == 0)
throw logic_error("list is empty");
if (cursor == head) // Remove first item
{
p = head;
head = head->next;
cursor = head;
}
else if (cursor->next != 0) // Remove middle item
{
p = cursor->next;
cursor->dataItem = p->dataItem;
cursor->next = p->next;
}
else // Remove last item
{
p = cursor;
for (q = head; q->next != cursor; q = q->next)
;
q->next = 0;
cursor = head;
}
delete p;
}
//--------------------------------------------------------------------
template < class T >
void List::replace(const T &newDataItem) throw (logic_error)
{
if (head == 0)
throw logic_error("list is empty");
cursor->dataItem = newDataItem;
}
//--------------------------------------------------------------------
template < class T >
void List::clear()
{
ListNode *p, // Points to successive nodes
*nextP; // Points to next node
p = head;
while (p != 0)
{
nextP = p->next;
delete p;
p = nextP;
}
head = 0;
cursor = 0;
}
//--------------------------------------------------------------------
template < class T >
bool List::isEmpty() const
{
return (head == 0);
}
//--------------------------------------------------------------------
template < class T >
bool List::isFull() const
{
T testDataItem;
ListNode *p;
try
{
p = new ListNode(testDataItem, 0);
}
catch (bad_alloc)
{
return true;
}
delete p;
return false;
}
//--------------------------------------------------------------------
template < class T >
void List::gotoBeginning() throw (logic_error)
{
if (head != 0)
cursor = head;
else
throw logic_error("list is empty");
}
//--------------------------------------------------------------------
template < class T >
void List::gotoEnd() throw (logic_error)
{
if (head != 0)
for (; cursor->next != 0; cursor = cursor->next)
;
else
throw logic_error("list is empty");
}
//--------------------------------------------------------------------
template < class T >
bool List::gotoNext()
{
bool result; // Result returned
if (cursor->next != 0)
{
cursor = cursor->next;
result = true;
}
else
result = false;
return result;
}
//--------------------------------------------------------------------
template < class T >
bool List::gotoPrior()
// If the cursor is not at the beginning of a list, then moves the
// cursor to the preceeding item in the list and returns 1.
// Otherwise, returns 0.
{
ListNode *p; // Pointer to prior node
int result; // Result returned
if (cursor != head)
{
for (p = head; p->next != cursor; p = p->next)
;
cursor = p;
result = true;
}
else
result = false;
return result;
}
//--------------------------------------------------------------------
template < class T >
T List::getCursor() const throw (logic_error)
{
if (head == 0)
throw logic_error("list is empty");
return cursor->dataItem;
}
//--------------------------------------------------------------------
template < class T >
void List::showStructure() const
{
ListNode *p; // Iterates through the list
if (head == 0)
cout << "Empty list" << endl;
else
{
for (p = head; p != 0; p = p->next)
if (p == cursor)
cout << "[" << p->dataItem << "] ";
else
cout << p->dataItem << " ";
cout << endl;
}
}
//--------------------------------------------------------------------
template < class T >
void List::moveToBeginning() throw (logic_error)
// Removes the item marked by the cursor from a list and
// reinserts it at the beginning of the list. Moves the cursor to the
// beginning of the list.
{
ListNode *p; // Pointer to prior node
// Requires that the list is not empty
if (head == 0)
throw logic_error("list is empty");
if (cursor != head)
{
for (p = head; p->next != cursor; p = p->next)
;
p->next = cursor->next;
cursor->next = head;
head = cursor;
}
}
//--------------------------------------------------------------------
template < class T >
void List::insertBefore(const T &newDataItem)
throw (bad_alloc)
// Inserts newDataItem before the cursor. If the list is empty, then
// newDataItem is inserted as the first (and only) item in the list.
// In either case, moves the cursor to newDataItem.
{
if (head == 0) // Empty list
{
head = new ListNode(newDataItem, 0);
cursor = head;
}
else // Before cursor
{
cursor->next = new ListNode(cursor->dataItem, cursor->next);
cursor->dataItem = newDataItem;
}
}
//--------------------------------------------------------------------
// hashtbl.h
//--------------------------------------------------------------------
template < class T, class KF >
class HashTbl
{
public:
HashTbl(int initTableSize);
~HashTbl();
void insert(const T &newDataItem) throw (bad_alloc);
bool remove(KF searchKey);
bool retrieve(KF searchKey, T &dataItem);
void clear();
bool isEmpty() const;
bool isFull() const;
void showStructure() const;
private:
int tableSize;
List *dataTable;
};
//--------------------------------------------------------------------
// hashtbl.cpp
//--------------------------------------------------------------------
template < class T, class KF >
HashTbl::HashTbl(int initTableSize) : tableSize(initTableSize)
{
dataTable = new List[tableSize];
}
template < class T, class KF >
HashTbl:: ~HashTbl()
{
delete[] dataTable;
}
template < class T, class KF >
void HashTbl::insert(const T &newDataItem) throw (bad_alloc)
{
int index = 0;
index = newDataItem.hash(newDataItem.getKey()) % tableSize;
if (dataTable[index].isEmpty())
dataTable[index].insert(newDataItem);
else
{
dataTable[index].gotoBeginning();
do
{
if (dataTable[index].getCursor().getKey() == newDataItem.getKey())
{
dataTable[index].replace(newDataItem);
return;
}
} while (dataTable[index].gotoNext());
dataTable[index].insert(newDataItem);
}
}
template < class T, class KF >
bool HashTbl::remove(KF searchKey)
{
T temp;
int index = 0;
index = temp.hash(searchKey) % tableSize;
if (dataTable[index].isEmpty())
return false;
dataTable[index].gotoBeginning();
do
{
if (dataTable[index].getCursor().getKey() == searchKey)
{
dataTable[index].remove();
return true;
}
} while (dataTable[index].gotoNext());
return false;
}
template < class T, class KF >
bool HashTbl::retrieve(KF searchKey, T &dataItem)
{
// apply two hash functions:
// convert string (searchkey) to integer
// and use the remainder method (% tableSize) to get the index
int index = 0;
index = dataItem.hash(searchKey) % tableSize;
if (dataTable[index].isEmpty())
return false;
dataTable[index].gotoBeginning();
do
{
if (dataTable[index].getCursor().getKey() == searchKey)
{
dataItem = dataTable[index].getCursor();
return true;
}
} while (dataTable[index].gotoNext());
return false;
}
template < class T, class KF >
void HashTbl::clear()
{
for (int i = 0; i
bool HashTbl::isEmpty() const
{
for (int i = 0; i
bool HashTbl::isFull() const
{
for (int i = 0; i
void HashTbl::showStructure() const
{
cout << "The Hash Table has the following entries" << endl;
for (int i = 0; i passwords(10);
Password tempPass;
string name; // user-supplied name
string pass; // user-supplied password
//bool userFound; // is user in table?
//*********************************************************
// Step 1: Read in the password file
//*********************************************************
ifstream passFile("password.txt");
if (!passFile)
{
cout << "Unable to open 'password.txt'!" << endl;
exit(0);
}
passFile >> tempPass.username;
while (!passFile.eof() && !passwords.isFull())
{
//**add line here to insert passwords into the HashTbl
passFile >> tempPass.password;
}
cout << "Printing the hash table:..." << endl;
//**add line here to show (print) the HashTbl
//*********************************************************
// Step 2: Prompt for a Login and Password and check if valid
//*********************************************************
cout << "Login: ";
while (cin >> name) // to quit, type CTRL Z in Visual C++
{
//**add line here to retrieve user from HashTbl
cout << "Password: ";
cin >> pass;
//**add lines here to compare retrieved user password to
//**input password and print "Authentication failure"
//**or "Authentication successful"
cout << "Login: ";
}
cout << endl;
}

More Related Content

Similar to C++ projectMachine Problem 7 - HashingWrite a program to do the .pdf

C++ Doubly-Linked ListsThe goal of the exercise is to implement a.pdf
C++ Doubly-Linked ListsThe goal of the exercise is to implement a.pdfC++ Doubly-Linked ListsThe goal of the exercise is to implement a.pdf
C++ Doubly-Linked ListsThe goal of the exercise is to implement a.pdfpoblettesedanoree498
 
Write a program that accepts an arithmetic expression of unsigned in.pdf
Write a program that accepts an arithmetic expression of unsigned in.pdfWrite a program that accepts an arithmetic expression of unsigned in.pdf
Write a program that accepts an arithmetic expression of unsigned in.pdfJUSTSTYLISH3B2MOHALI
 
Can someone solve the TODO parts of the following problem i.pdf
Can someone solve the TODO parts of the following problem i.pdfCan someone solve the TODO parts of the following problem i.pdf
Can someone solve the TODO parts of the following problem i.pdfakshpatil4
 
PLEASE MAKE SURE THE PROGRAM IS ASKING FOR INPUT FROM USER TO ADD OR.pdf
PLEASE MAKE SURE THE PROGRAM IS ASKING FOR INPUT FROM USER TO ADD OR.pdfPLEASE MAKE SURE THE PROGRAM IS ASKING FOR INPUT FROM USER TO ADD OR.pdf
PLEASE MAKE SURE THE PROGRAM IS ASKING FOR INPUT FROM USER TO ADD OR.pdfmallik3000
 
Data structures stacks
Data structures   stacksData structures   stacks
Data structures stacksmaamir farooq
 
Please need help on following program using c++ language. Please inc.pdf
Please need help on following program using c++ language. Please inc.pdfPlease need help on following program using c++ language. Please inc.pdf
Please need help on following program using c++ language. Please inc.pdfnitinarora01
 
lab08build.bat@echo offclsset DRIVE_LETTER=1s.docx
lab08build.bat@echo offclsset DRIVE_LETTER=1s.docxlab08build.bat@echo offclsset DRIVE_LETTER=1s.docx
lab08build.bat@echo offclsset DRIVE_LETTER=1s.docxDIPESH30
 
–PLS write program in c++Recursive Linked List OperationsWrite a.pdf
–PLS write program in c++Recursive Linked List OperationsWrite a.pdf–PLS write program in c++Recursive Linked List OperationsWrite a.pdf
–PLS write program in c++Recursive Linked List OperationsWrite a.pdfpasqualealvarez467
 
1- The design of a singly-linked list below is a picture of the functi (1).pdf
1- The design of a singly-linked list below is a picture of the functi (1).pdf1- The design of a singly-linked list below is a picture of the functi (1).pdf
1- The design of a singly-linked list below is a picture of the functi (1).pdfafgt2012
 
How do you stop infinite loop Because I believe that it is making a.pdf
How do you stop infinite loop Because I believe that it is making a.pdfHow do you stop infinite loop Because I believe that it is making a.pdf
How do you stop infinite loop Because I believe that it is making a.pdffeelinggift
 
Please solve the TODO parts of the following probelm incl.pdf
Please solve the TODO parts of the following probelm  incl.pdfPlease solve the TODO parts of the following probelm  incl.pdf
Please solve the TODO parts of the following probelm incl.pdfaggarwalopticalsco
 
could you implement this function please, im having issues with it..pdf
could you implement this function please, im having issues with it..pdfcould you implement this function please, im having issues with it..pdf
could you implement this function please, im having issues with it..pdfferoz544
 
03.DS_Store__MACOSX03._.DS_Store03A2.DS_Store__.docx
03.DS_Store__MACOSX03._.DS_Store03A2.DS_Store__.docx03.DS_Store__MACOSX03._.DS_Store03A2.DS_Store__.docx
03.DS_Store__MACOSX03._.DS_Store03A2.DS_Store__.docxhoney725342
 
Lab Week 2 Game Programming.docx
Lab Week 2 Game Programming.docxLab Week 2 Game Programming.docx
Lab Week 2 Game Programming.docxteyaj1
 
Note             Given Code modified as required and required met.pdf
Note             Given Code modified as required and required met.pdfNote             Given Code modified as required and required met.pdf
Note             Given Code modified as required and required met.pdfAnkitchhabra28
 
Program In C You are required to write an interactive C program that.pdf
Program In C You are required to write an interactive C program that.pdfProgram In C You are required to write an interactive C program that.pdf
Program In C You are required to write an interactive C program that.pdfamitbagga0808
 

Similar to C++ projectMachine Problem 7 - HashingWrite a program to do the .pdf (20)

C++ Doubly-Linked ListsThe goal of the exercise is to implement a.pdf
C++ Doubly-Linked ListsThe goal of the exercise is to implement a.pdfC++ Doubly-Linked ListsThe goal of the exercise is to implement a.pdf
C++ Doubly-Linked ListsThe goal of the exercise is to implement a.pdf
 
Write a program that accepts an arithmetic expression of unsigned in.pdf
Write a program that accepts an arithmetic expression of unsigned in.pdfWrite a program that accepts an arithmetic expression of unsigned in.pdf
Write a program that accepts an arithmetic expression of unsigned in.pdf
 
Can someone solve the TODO parts of the following problem i.pdf
Can someone solve the TODO parts of the following problem i.pdfCan someone solve the TODO parts of the following problem i.pdf
Can someone solve the TODO parts of the following problem i.pdf
 
PLEASE MAKE SURE THE PROGRAM IS ASKING FOR INPUT FROM USER TO ADD OR.pdf
PLEASE MAKE SURE THE PROGRAM IS ASKING FOR INPUT FROM USER TO ADD OR.pdfPLEASE MAKE SURE THE PROGRAM IS ASKING FOR INPUT FROM USER TO ADD OR.pdf
PLEASE MAKE SURE THE PROGRAM IS ASKING FOR INPUT FROM USER TO ADD OR.pdf
 
Unit - 2.pdf
Unit - 2.pdfUnit - 2.pdf
Unit - 2.pdf
 
Data structures stacks
Data structures   stacksData structures   stacks
Data structures stacks
 
Unit7 C
Unit7 CUnit7 C
Unit7 C
 
C++11 - STL Additions
C++11 - STL AdditionsC++11 - STL Additions
C++11 - STL Additions
 
Please need help on following program using c++ language. Please inc.pdf
Please need help on following program using c++ language. Please inc.pdfPlease need help on following program using c++ language. Please inc.pdf
Please need help on following program using c++ language. Please inc.pdf
 
lab08build.bat@echo offclsset DRIVE_LETTER=1s.docx
lab08build.bat@echo offclsset DRIVE_LETTER=1s.docxlab08build.bat@echo offclsset DRIVE_LETTER=1s.docx
lab08build.bat@echo offclsset DRIVE_LETTER=1s.docx
 
–PLS write program in c++Recursive Linked List OperationsWrite a.pdf
–PLS write program in c++Recursive Linked List OperationsWrite a.pdf–PLS write program in c++Recursive Linked List OperationsWrite a.pdf
–PLS write program in c++Recursive Linked List OperationsWrite a.pdf
 
1- The design of a singly-linked list below is a picture of the functi (1).pdf
1- The design of a singly-linked list below is a picture of the functi (1).pdf1- The design of a singly-linked list below is a picture of the functi (1).pdf
1- The design of a singly-linked list below is a picture of the functi (1).pdf
 
How do you stop infinite loop Because I believe that it is making a.pdf
How do you stop infinite loop Because I believe that it is making a.pdfHow do you stop infinite loop Because I believe that it is making a.pdf
How do you stop infinite loop Because I believe that it is making a.pdf
 
DS Code (CWH).docx
DS Code (CWH).docxDS Code (CWH).docx
DS Code (CWH).docx
 
Please solve the TODO parts of the following probelm incl.pdf
Please solve the TODO parts of the following probelm  incl.pdfPlease solve the TODO parts of the following probelm  incl.pdf
Please solve the TODO parts of the following probelm incl.pdf
 
could you implement this function please, im having issues with it..pdf
could you implement this function please, im having issues with it..pdfcould you implement this function please, im having issues with it..pdf
could you implement this function please, im having issues with it..pdf
 
03.DS_Store__MACOSX03._.DS_Store03A2.DS_Store__.docx
03.DS_Store__MACOSX03._.DS_Store03A2.DS_Store__.docx03.DS_Store__MACOSX03._.DS_Store03A2.DS_Store__.docx
03.DS_Store__MACOSX03._.DS_Store03A2.DS_Store__.docx
 
Lab Week 2 Game Programming.docx
Lab Week 2 Game Programming.docxLab Week 2 Game Programming.docx
Lab Week 2 Game Programming.docx
 
Note             Given Code modified as required and required met.pdf
Note             Given Code modified as required and required met.pdfNote             Given Code modified as required and required met.pdf
Note             Given Code modified as required and required met.pdf
 
Program In C You are required to write an interactive C program that.pdf
Program In C You are required to write an interactive C program that.pdfProgram In C You are required to write an interactive C program that.pdf
Program In C You are required to write an interactive C program that.pdf
 

More from feelinggift

A) Which of the following element is seen in all organic molecules Si.pdf
A) Which of the following element is seen in all organic molecules Si.pdfA) Which of the following element is seen in all organic molecules Si.pdf
A) Which of the following element is seen in all organic molecules Si.pdffeelinggift
 
Given an ArrayList, write a Java method that returns a new ArrayList.pdf
Given an ArrayList, write a Java method that returns a new ArrayList.pdfGiven an ArrayList, write a Java method that returns a new ArrayList.pdf
Given an ArrayList, write a Java method that returns a new ArrayList.pdffeelinggift
 
Write an MSP430g2553 C program to drive a continually scrolling mess.pdf
Write an MSP430g2553 C program to drive a continually scrolling mess.pdfWrite an MSP430g2553 C program to drive a continually scrolling mess.pdf
Write an MSP430g2553 C program to drive a continually scrolling mess.pdffeelinggift
 
Which of the following is NOT a financial measurement needed to see .pdf
Which of the following is NOT a financial measurement needed to see .pdfWhich of the following is NOT a financial measurement needed to see .pdf
Which of the following is NOT a financial measurement needed to see .pdffeelinggift
 
Which process uses chemiosmosis A. Pyruvate oxidation B. Electron .pdf
Which process uses chemiosmosis  A. Pyruvate oxidation  B. Electron .pdfWhich process uses chemiosmosis  A. Pyruvate oxidation  B. Electron .pdf
Which process uses chemiosmosis A. Pyruvate oxidation B. Electron .pdffeelinggift
 
What motives do corporate executives have that force them to embrace.pdf
What motives do corporate executives have that force them to embrace.pdfWhat motives do corporate executives have that force them to embrace.pdf
What motives do corporate executives have that force them to embrace.pdffeelinggift
 
when are business cases or project charters overkillSolutionP.pdf
when are business cases or project charters overkillSolutionP.pdfwhen are business cases or project charters overkillSolutionP.pdf
when are business cases or project charters overkillSolutionP.pdffeelinggift
 
True or False The Congressional Budget Office projects that approxi.pdf
True or False The Congressional Budget Office projects that approxi.pdfTrue or False The Congressional Budget Office projects that approxi.pdf
True or False The Congressional Budget Office projects that approxi.pdffeelinggift
 
Using the space provided compose an ESSAY concerning the following qu.pdf
Using the space provided compose an ESSAY concerning the following qu.pdfUsing the space provided compose an ESSAY concerning the following qu.pdf
Using the space provided compose an ESSAY concerning the following qu.pdffeelinggift
 
We continually hear about interest groups in the news. Understanding.pdf
We continually hear about interest groups in the news. Understanding.pdfWe continually hear about interest groups in the news. Understanding.pdf
We continually hear about interest groups in the news. Understanding.pdffeelinggift
 
View transaction list Journal entry worksheet 6 9 The company receive.pdf
View transaction list Journal entry worksheet 6 9 The company receive.pdfView transaction list Journal entry worksheet 6 9 The company receive.pdf
View transaction list Journal entry worksheet 6 9 The company receive.pdffeelinggift
 
Physical security is a fundamental component of any secure infrastru.pdf
Physical security is a fundamental component of any secure infrastru.pdfPhysical security is a fundamental component of any secure infrastru.pdf
Physical security is a fundamental component of any secure infrastru.pdffeelinggift
 
TrueFalse Verilog is case-insensitive TF Verilog has constructs.pdf
TrueFalse Verilog is case-insensitive TF Verilog has constructs.pdfTrueFalse Verilog is case-insensitive TF Verilog has constructs.pdf
TrueFalse Verilog is case-insensitive TF Verilog has constructs.pdffeelinggift
 
This is a homework assignment that I have for my Java coding class. .pdf
This is a homework assignment that I have for my Java coding class. .pdfThis is a homework assignment that I have for my Java coding class. .pdf
This is a homework assignment that I have for my Java coding class. .pdffeelinggift
 
The Jannuschs operated Festival Foods, a busi- ness that served conc.pdf
The Jannuschs operated Festival Foods, a busi- ness that served conc.pdfThe Jannuschs operated Festival Foods, a busi- ness that served conc.pdf
The Jannuschs operated Festival Foods, a busi- ness that served conc.pdffeelinggift
 
The first thermodynamic law for a system of charged molecules in elec.pdf
The first thermodynamic law for a system of charged molecules in elec.pdfThe first thermodynamic law for a system of charged molecules in elec.pdf
The first thermodynamic law for a system of charged molecules in elec.pdffeelinggift
 
show all of your work to arrive a final result Simple Interest Simpl.pdf
show all of your work to arrive a final result Simple Interest Simpl.pdfshow all of your work to arrive a final result Simple Interest Simpl.pdf
show all of your work to arrive a final result Simple Interest Simpl.pdffeelinggift
 
Terms from which students can chooseMacrophages; •Only one.pdf
Terms from which students can chooseMacrophages; •Only one.pdfTerms from which students can chooseMacrophages; •Only one.pdf
Terms from which students can chooseMacrophages; •Only one.pdffeelinggift
 
Simulate the Stakeholder deliverable for the development of an onlin.pdf
Simulate the Stakeholder deliverable for the development of an onlin.pdfSimulate the Stakeholder deliverable for the development of an onlin.pdf
Simulate the Stakeholder deliverable for the development of an onlin.pdffeelinggift
 
I want to write this program in java.Write a simple airline ticket.pdf
I want to write this program in java.Write a simple airline ticket.pdfI want to write this program in java.Write a simple airline ticket.pdf
I want to write this program in java.Write a simple airline ticket.pdffeelinggift
 

More from feelinggift (20)

A) Which of the following element is seen in all organic molecules Si.pdf
A) Which of the following element is seen in all organic molecules Si.pdfA) Which of the following element is seen in all organic molecules Si.pdf
A) Which of the following element is seen in all organic molecules Si.pdf
 
Given an ArrayList, write a Java method that returns a new ArrayList.pdf
Given an ArrayList, write a Java method that returns a new ArrayList.pdfGiven an ArrayList, write a Java method that returns a new ArrayList.pdf
Given an ArrayList, write a Java method that returns a new ArrayList.pdf
 
Write an MSP430g2553 C program to drive a continually scrolling mess.pdf
Write an MSP430g2553 C program to drive a continually scrolling mess.pdfWrite an MSP430g2553 C program to drive a continually scrolling mess.pdf
Write an MSP430g2553 C program to drive a continually scrolling mess.pdf
 
Which of the following is NOT a financial measurement needed to see .pdf
Which of the following is NOT a financial measurement needed to see .pdfWhich of the following is NOT a financial measurement needed to see .pdf
Which of the following is NOT a financial measurement needed to see .pdf
 
Which process uses chemiosmosis A. Pyruvate oxidation B. Electron .pdf
Which process uses chemiosmosis  A. Pyruvate oxidation  B. Electron .pdfWhich process uses chemiosmosis  A. Pyruvate oxidation  B. Electron .pdf
Which process uses chemiosmosis A. Pyruvate oxidation B. Electron .pdf
 
What motives do corporate executives have that force them to embrace.pdf
What motives do corporate executives have that force them to embrace.pdfWhat motives do corporate executives have that force them to embrace.pdf
What motives do corporate executives have that force them to embrace.pdf
 
when are business cases or project charters overkillSolutionP.pdf
when are business cases or project charters overkillSolutionP.pdfwhen are business cases or project charters overkillSolutionP.pdf
when are business cases or project charters overkillSolutionP.pdf
 
True or False The Congressional Budget Office projects that approxi.pdf
True or False The Congressional Budget Office projects that approxi.pdfTrue or False The Congressional Budget Office projects that approxi.pdf
True or False The Congressional Budget Office projects that approxi.pdf
 
Using the space provided compose an ESSAY concerning the following qu.pdf
Using the space provided compose an ESSAY concerning the following qu.pdfUsing the space provided compose an ESSAY concerning the following qu.pdf
Using the space provided compose an ESSAY concerning the following qu.pdf
 
We continually hear about interest groups in the news. Understanding.pdf
We continually hear about interest groups in the news. Understanding.pdfWe continually hear about interest groups in the news. Understanding.pdf
We continually hear about interest groups in the news. Understanding.pdf
 
View transaction list Journal entry worksheet 6 9 The company receive.pdf
View transaction list Journal entry worksheet 6 9 The company receive.pdfView transaction list Journal entry worksheet 6 9 The company receive.pdf
View transaction list Journal entry worksheet 6 9 The company receive.pdf
 
Physical security is a fundamental component of any secure infrastru.pdf
Physical security is a fundamental component of any secure infrastru.pdfPhysical security is a fundamental component of any secure infrastru.pdf
Physical security is a fundamental component of any secure infrastru.pdf
 
TrueFalse Verilog is case-insensitive TF Verilog has constructs.pdf
TrueFalse Verilog is case-insensitive TF Verilog has constructs.pdfTrueFalse Verilog is case-insensitive TF Verilog has constructs.pdf
TrueFalse Verilog is case-insensitive TF Verilog has constructs.pdf
 
This is a homework assignment that I have for my Java coding class. .pdf
This is a homework assignment that I have for my Java coding class. .pdfThis is a homework assignment that I have for my Java coding class. .pdf
This is a homework assignment that I have for my Java coding class. .pdf
 
The Jannuschs operated Festival Foods, a busi- ness that served conc.pdf
The Jannuschs operated Festival Foods, a busi- ness that served conc.pdfThe Jannuschs operated Festival Foods, a busi- ness that served conc.pdf
The Jannuschs operated Festival Foods, a busi- ness that served conc.pdf
 
The first thermodynamic law for a system of charged molecules in elec.pdf
The first thermodynamic law for a system of charged molecules in elec.pdfThe first thermodynamic law for a system of charged molecules in elec.pdf
The first thermodynamic law for a system of charged molecules in elec.pdf
 
show all of your work to arrive a final result Simple Interest Simpl.pdf
show all of your work to arrive a final result Simple Interest Simpl.pdfshow all of your work to arrive a final result Simple Interest Simpl.pdf
show all of your work to arrive a final result Simple Interest Simpl.pdf
 
Terms from which students can chooseMacrophages; •Only one.pdf
Terms from which students can chooseMacrophages; •Only one.pdfTerms from which students can chooseMacrophages; •Only one.pdf
Terms from which students can chooseMacrophages; •Only one.pdf
 
Simulate the Stakeholder deliverable for the development of an onlin.pdf
Simulate the Stakeholder deliverable for the development of an onlin.pdfSimulate the Stakeholder deliverable for the development of an onlin.pdf
Simulate the Stakeholder deliverable for the development of an onlin.pdf
 
I want to write this program in java.Write a simple airline ticket.pdf
I want to write this program in java.Write a simple airline ticket.pdfI want to write this program in java.Write a simple airline ticket.pdf
I want to write this program in java.Write a simple airline ticket.pdf
 

Recently uploaded

Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...M56BOOKSTORE PRODUCT/SERVICE
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 

Recently uploaded (20)

Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 

C++ projectMachine Problem 7 - HashingWrite a program to do the .pdf

  • 1. C++ project Machine Problem 7 - Hashing Write a program to do the following: loads username/password sets from the file password.txt and insert them into the hash table until the end of file is reached on password.txt. The password.txt file will look something like this with one username/password set per line. mary changeMe! The program will then present a login prompt, read one username, present a password prompt, and after looking up the username's password in the hash table, will print either "Authentication successful" or "Authentication failure". The above step will be repeated until the end of the input data (EOF) is reached on the console input stream (cin). The EOF character on the PC's is the CTRL Z character. To convert from a string to an integer, we can add the ascii value of each character together. For instance, Mary's conversion from string to integer might look something like this: 109('m') + 97('a') + 114('r') + 121('y')=441 We've converted the string to an integer, but we still need to convert the integer to an index. For an array of 10 elements we can divide by 10 and use the remainder as an index. Combining these two hash functions, we will get Mary's index to be: 441 % 10 = 1 Your primary tasks for this homework are to edit the login.cpp to replace the comments with lines so that it does the following: Insert passwords into the Hash Table. Retrieve one user's Password structure from the Hash Table. Compare retrieved user password to input password and print "Authentication failure" or "Authentication successful." //-------------------------------------------------------------------- // // listlnk.h //
  • 2. //-------------------------------------------------------------------- #pragma warning( disable : 4290 ) #include #include #include #include #include #include #include using namespace std; template < class T > // Forward declaration of the List class class List; template < class T > class ListNode // Facilitator class for the List class { private: ListNode(const T &nodeData, ListNode *nextPtr); T dataItem; // List data item ListNode *next; // Pointer to the next list node friend class List; }; //-------------------------------------------------------------------- template < class T > class List { public: List(int ignored = 0); ~List(); void insert(const T &newData) throw (bad_alloc); // Insert after cursor
  • 3. void remove() throw (logic_error); // Remove data item void replace(const T &newData) throw (logic_error); // Replace data item void clear(); bool isEmpty() const; bool isFull() const; // List iteration operations void gotoBeginning() throw (logic_error); void gotoEnd() throw (logic_error); bool gotoNext(); bool gotoPrior(); T getCursor() const throw (logic_error); // Return item void showStructure() const; void moveToBeginning() throw (logic_error); // Move to beginning void insertBefore(const T &newElement) throw (bad_alloc); // Insert before cursor private: ListNode *head, // Pointer to the beginning of the list *cursor; // Cursor pointer }; //-------------------------------------------------------------------- // // listlnk.cpp // //-------------------------------------------------------------------- template < class T > ListNode::ListNode(const T &nodeDataItem, ListNode *nextPtr) : dataItem(nodeDataItem), next(nextPtr) {} //-------------------------------------------------------------------- template < class T >
  • 4. List::List(int ignored) : head(0), cursor(0) {} //-------------------------------------------------------------------- template < class T > List:: ~List() { clear(); } //-------------------------------------------------------------------- template < class T > void List::insert(const T &newDataItem) throw (bad_alloc) { if (head == 0) // Empty list { head = new ListNode(newDataItem, 0); cursor = head; } else // After cursor { cursor->next = new ListNode(newDataItem, cursor->next); cursor = cursor->next; } } //-------------------------------------------------------------------- template < class T > void List::remove() throw (logic_error) { ListNode *p, // Pointer to removed node *q; // Pointer to prior node
  • 5. // Requires that the list is not empty if (head == 0) throw logic_error("list is empty"); if (cursor == head) // Remove first item { p = head; head = head->next; cursor = head; } else if (cursor->next != 0) // Remove middle item { p = cursor->next; cursor->dataItem = p->dataItem; cursor->next = p->next; } else // Remove last item { p = cursor; for (q = head; q->next != cursor; q = q->next) ; q->next = 0; cursor = head; } delete p; } //-------------------------------------------------------------------- template < class T > void List::replace(const T &newDataItem) throw (logic_error) { if (head == 0) throw logic_error("list is empty");
  • 6. cursor->dataItem = newDataItem; } //-------------------------------------------------------------------- template < class T > void List::clear() { ListNode *p, // Points to successive nodes *nextP; // Points to next node p = head; while (p != 0) { nextP = p->next; delete p; p = nextP; } head = 0; cursor = 0; } //-------------------------------------------------------------------- template < class T > bool List::isEmpty() const { return (head == 0); } //-------------------------------------------------------------------- template < class T > bool List::isFull() const { T testDataItem; ListNode *p;
  • 7. try { p = new ListNode(testDataItem, 0); } catch (bad_alloc) { return true; } delete p; return false; } //-------------------------------------------------------------------- template < class T > void List::gotoBeginning() throw (logic_error) { if (head != 0) cursor = head; else throw logic_error("list is empty"); } //-------------------------------------------------------------------- template < class T > void List::gotoEnd() throw (logic_error) { if (head != 0) for (; cursor->next != 0; cursor = cursor->next) ; else throw logic_error("list is empty"); }
  • 8. //-------------------------------------------------------------------- template < class T > bool List::gotoNext() { bool result; // Result returned if (cursor->next != 0) { cursor = cursor->next; result = true; } else result = false; return result; } //-------------------------------------------------------------------- template < class T > bool List::gotoPrior() // If the cursor is not at the beginning of a list, then moves the // cursor to the preceeding item in the list and returns 1. // Otherwise, returns 0. { ListNode *p; // Pointer to prior node int result; // Result returned if (cursor != head) { for (p = head; p->next != cursor; p = p->next) ;
  • 9. cursor = p; result = true; } else result = false; return result; } //-------------------------------------------------------------------- template < class T > T List::getCursor() const throw (logic_error) { if (head == 0) throw logic_error("list is empty"); return cursor->dataItem; } //-------------------------------------------------------------------- template < class T > void List::showStructure() const { ListNode *p; // Iterates through the list if (head == 0) cout << "Empty list" << endl; else { for (p = head; p != 0; p = p->next) if (p == cursor) cout << "[" << p->dataItem << "] "; else cout << p->dataItem << " ";
  • 10. cout << endl; } } //-------------------------------------------------------------------- template < class T > void List::moveToBeginning() throw (logic_error) // Removes the item marked by the cursor from a list and // reinserts it at the beginning of the list. Moves the cursor to the // beginning of the list. { ListNode *p; // Pointer to prior node // Requires that the list is not empty if (head == 0) throw logic_error("list is empty"); if (cursor != head) { for (p = head; p->next != cursor; p = p->next) ; p->next = cursor->next; cursor->next = head; head = cursor; } } //-------------------------------------------------------------------- template < class T > void List::insertBefore(const T &newDataItem) throw (bad_alloc) // Inserts newDataItem before the cursor. If the list is empty, then // newDataItem is inserted as the first (and only) item in the list.
  • 11. // In either case, moves the cursor to newDataItem. { if (head == 0) // Empty list { head = new ListNode(newDataItem, 0); cursor = head; } else // Before cursor { cursor->next = new ListNode(cursor->dataItem, cursor->next); cursor->dataItem = newDataItem; } } //-------------------------------------------------------------------- // hashtbl.h //-------------------------------------------------------------------- template < class T, class KF > class HashTbl { public: HashTbl(int initTableSize); ~HashTbl(); void insert(const T &newDataItem) throw (bad_alloc); bool remove(KF searchKey); bool retrieve(KF searchKey, T &dataItem); void clear(); bool isEmpty() const; bool isFull() const; void showStructure() const;
  • 12. private: int tableSize; List *dataTable; }; //-------------------------------------------------------------------- // hashtbl.cpp //-------------------------------------------------------------------- template < class T, class KF > HashTbl::HashTbl(int initTableSize) : tableSize(initTableSize) { dataTable = new List[tableSize]; } template < class T, class KF > HashTbl:: ~HashTbl() { delete[] dataTable; } template < class T, class KF > void HashTbl::insert(const T &newDataItem) throw (bad_alloc) { int index = 0; index = newDataItem.hash(newDataItem.getKey()) % tableSize; if (dataTable[index].isEmpty()) dataTable[index].insert(newDataItem); else { dataTable[index].gotoBeginning(); do { if (dataTable[index].getCursor().getKey() == newDataItem.getKey())
  • 13. { dataTable[index].replace(newDataItem); return; } } while (dataTable[index].gotoNext()); dataTable[index].insert(newDataItem); } } template < class T, class KF > bool HashTbl::remove(KF searchKey) { T temp; int index = 0; index = temp.hash(searchKey) % tableSize; if (dataTable[index].isEmpty()) return false; dataTable[index].gotoBeginning(); do { if (dataTable[index].getCursor().getKey() == searchKey) { dataTable[index].remove(); return true; } } while (dataTable[index].gotoNext()); return false; } template < class T, class KF > bool HashTbl::retrieve(KF searchKey, T &dataItem) {
  • 14. // apply two hash functions: // convert string (searchkey) to integer // and use the remainder method (% tableSize) to get the index int index = 0; index = dataItem.hash(searchKey) % tableSize; if (dataTable[index].isEmpty()) return false; dataTable[index].gotoBeginning(); do { if (dataTable[index].getCursor().getKey() == searchKey) { dataItem = dataTable[index].getCursor(); return true; } } while (dataTable[index].gotoNext()); return false; } template < class T, class KF > void HashTbl::clear() { for (int i = 0; i bool HashTbl::isEmpty() const { for (int i = 0; i bool HashTbl::isFull() const { for (int i = 0; i void HashTbl::showStructure() const { cout << "The Hash Table has the following entries" << endl;
  • 15. for (int i = 0; i passwords(10); Password tempPass; string name; // user-supplied name string pass; // user-supplied password //bool userFound; // is user in table? //********************************************************* // Step 1: Read in the password file //********************************************************* ifstream passFile("password.txt"); if (!passFile) { cout << "Unable to open 'password.txt'!" << endl; exit(0); } passFile >> tempPass.username; while (!passFile.eof() && !passwords.isFull()) { //**add line here to insert passwords into the HashTbl passFile >> tempPass.password; } cout << "Printing the hash table:..." << endl; //**add line here to show (print) the HashTbl //********************************************************* // Step 2: Prompt for a Login and Password and check if valid //********************************************************* cout << "Login: "; while (cin >> name) // to quit, type CTRL Z in Visual C++ { //**add line here to retrieve user from HashTbl
  • 16. cout << "Password: "; cin >> pass; //**add lines here to compare retrieved user password to //**input password and print "Authentication failure" //**or "Authentication successful" cout << "Login: "; } cout << endl; } Please upload the following: The class .cpp file The main program The class .h file Output File Solution #include #include #include #include #include #include #include using namespace std; template < class T > // Forward declaration of the List class class List; template < class T > class ListNode // Facilitator class for the List class { private:
  • 17. ListNode(const T &nodeData, ListNode *nextPtr); T dataItem; // List data item ListNode *next; // Pointer to the next list node friend class List; }; //-------------------------------------------------------------------- template < class T > class List { public: List(int ignored = 0); ~List(); void insert(const T &newData) throw (bad_alloc); // Insert after cursor void remove() throw (logic_error); // Remove data item void replace(const T &newData) throw (logic_error); // Replace data item void clear(); bool isEmpty() const; bool isFull() const; // List iteration operations void gotoBeginning() throw (logic_error); void gotoEnd() throw (logic_error); bool gotoNext(); bool gotoPrior(); T getCursor() const throw (logic_error); // Return item void showStructure() const; void moveToBeginning() throw (logic_error); // Move to beginning void insertBefore(const T &newElement) throw (bad_alloc); // Insert before cursor private:
  • 18. ListNode *head, // Pointer to the beginning of the list *cursor; // Cursor pointer }; //-------------------------------------------------------------------- // // listlnk.cpp // //-------------------------------------------------------------------- template < class T > ListNode::ListNode(const T &nodeDataItem, ListNode *nextPtr) : dataItem(nodeDataItem), next(nextPtr) {} //-------------------------------------------------------------------- template < class T > List::List(int ignored) : head(0), cursor(0) {} //-------------------------------------------------------------------- template < class T > List:: ~List() { clear(); } //-------------------------------------------------------------------- template < class T > void List::insert(const T &newDataItem) throw (bad_alloc) { if (head == 0) // Empty list {
  • 19. head = new ListNode(newDataItem, 0); cursor = head; } else // After cursor { cursor->next = new ListNode(newDataItem, cursor->next); cursor = cursor->next; } } //-------------------------------------------------------------------- template < class T > void List::remove() throw (logic_error) { ListNode *p, // Pointer to removed node *q; // Pointer to prior node // Requires that the list is not empty if (head == 0) throw logic_error("list is empty"); if (cursor == head) // Remove first item { p = head; head = head->next; cursor = head; } else if (cursor->next != 0) // Remove middle item { p = cursor->next; cursor->dataItem = p->dataItem; cursor->next = p->next; } else // Remove last item {
  • 20. p = cursor; for (q = head; q->next != cursor; q = q->next) ; q->next = 0; cursor = head; } delete p; } //-------------------------------------------------------------------- template < class T > void List::replace(const T &newDataItem) throw (logic_error) { if (head == 0) throw logic_error("list is empty"); cursor->dataItem = newDataItem; } //-------------------------------------------------------------------- template < class T > void List::clear() { ListNode *p, // Points to successive nodes *nextP; // Points to next node p = head; while (p != 0) { nextP = p->next; delete p; p = nextP; }
  • 21. head = 0; cursor = 0; } //-------------------------------------------------------------------- template < class T > bool List::isEmpty() const { return (head == 0); } //-------------------------------------------------------------------- template < class T > bool List::isFull() const { T testDataItem; ListNode *p; try { p = new ListNode(testDataItem, 0); } catch (bad_alloc) { return true; } delete p; return false; } //-------------------------------------------------------------------- template < class T > void List::gotoBeginning() throw (logic_error)
  • 22. { if (head != 0) cursor = head; else throw logic_error("list is empty"); } //-------------------------------------------------------------------- template < class T > void List::gotoEnd() throw (logic_error) { if (head != 0) for (; cursor->next != 0; cursor = cursor->next) ; else throw logic_error("list is empty"); } //-------------------------------------------------------------------- template < class T > bool List::gotoNext() { bool result; // Result returned if (cursor->next != 0) { cursor = cursor->next; result = true; } else result = false; return result; }
  • 23. //-------------------------------------------------------------------- template < class T > bool List::gotoPrior() // If the cursor is not at the beginning of a list, then moves the // cursor to the preceeding item in the list and returns 1. // Otherwise, returns 0. { ListNode *p; // Pointer to prior node int result; // Result returned if (cursor != head) { for (p = head; p->next != cursor; p = p->next) ; cursor = p; result = true; } else result = false; return result; } //-------------------------------------------------------------------- template < class T > T List::getCursor() const throw (logic_error) { if (head == 0) throw logic_error("list is empty"); return cursor->dataItem;
  • 24. } //-------------------------------------------------------------------- template < class T > void List::showStructure() const { ListNode *p; // Iterates through the list if (head == 0) cout << "Empty list" << endl; else { for (p = head; p != 0; p = p->next) if (p == cursor) cout << "[" << p->dataItem << "] "; else cout << p->dataItem << " "; cout << endl; } } //-------------------------------------------------------------------- template < class T > void List::moveToBeginning() throw (logic_error) // Removes the item marked by the cursor from a list and // reinserts it at the beginning of the list. Moves the cursor to the // beginning of the list. { ListNode *p; // Pointer to prior node // Requires that the list is not empty if (head == 0) throw logic_error("list is empty");
  • 25. if (cursor != head) { for (p = head; p->next != cursor; p = p->next) ; p->next = cursor->next; cursor->next = head; head = cursor; } } //-------------------------------------------------------------------- template < class T > void List::insertBefore(const T &newDataItem) throw (bad_alloc) // Inserts newDataItem before the cursor. If the list is empty, then // newDataItem is inserted as the first (and only) item in the list. // In either case, moves the cursor to newDataItem. { if (head == 0) // Empty list { head = new ListNode(newDataItem, 0); cursor = head; } else // Before cursor { cursor->next = new ListNode(cursor->dataItem, cursor->next); cursor->dataItem = newDataItem; } } //-------------------------------------------------------------------- // hashtbl.h //--------------------------------------------------------------------
  • 26. template < class T, class KF > class HashTbl { public: HashTbl(int initTableSize); ~HashTbl(); void insert(const T &newDataItem) throw (bad_alloc); bool remove(KF searchKey); bool retrieve(KF searchKey, T &dataItem); void clear(); bool isEmpty() const; bool isFull() const; void showStructure() const; private: int tableSize; List *dataTable; }; //-------------------------------------------------------------------- // hashtbl.cpp //-------------------------------------------------------------------- template < class T, class KF > HashTbl::HashTbl(int initTableSize) : tableSize(initTableSize) { dataTable = new List[tableSize]; } template < class T, class KF > HashTbl:: ~HashTbl()
  • 27. { delete[] dataTable; } template < class T, class KF > void HashTbl::insert(const T &newDataItem) throw (bad_alloc) { int index = 0; index = newDataItem.hash(newDataItem.getKey()) % tableSize; if (dataTable[index].isEmpty()) dataTable[index].insert(newDataItem); else { dataTable[index].gotoBeginning(); do { if (dataTable[index].getCursor().getKey() == newDataItem.getKey()) { dataTable[index].replace(newDataItem); return; } } while (dataTable[index].gotoNext()); dataTable[index].insert(newDataItem); } } template < class T, class KF > bool HashTbl::remove(KF searchKey) { T temp; int index = 0; index = temp.hash(searchKey) % tableSize; if (dataTable[index].isEmpty())
  • 28. return false; dataTable[index].gotoBeginning(); do { if (dataTable[index].getCursor().getKey() == searchKey) { dataTable[index].remove(); return true; } } while (dataTable[index].gotoNext()); return false; } template < class T, class KF > bool HashTbl::retrieve(KF searchKey, T &dataItem) { // apply two hash functions: // convert string (searchkey) to integer // and use the remainder method (% tableSize) to get the index int index = 0; index = dataItem.hash(searchKey) % tableSize; if (dataTable[index].isEmpty()) return false; dataTable[index].gotoBeginning(); do { if (dataTable[index].getCursor().getKey() == searchKey) { dataItem = dataTable[index].getCursor(); return true; }
  • 29. } while (dataTable[index].gotoNext()); return false; } template < class T, class KF > void HashTbl::clear() { for (int i = 0; i bool HashTbl::isEmpty() const { for (int i = 0; i bool HashTbl::isFull() const { for (int i = 0; i void HashTbl::showStructure() const { cout << "The Hash Table has the following entries" << endl; for (int i = 0; i passwords(10); Password tempPass; string name; // user-supplied name string pass; // user-supplied password //bool userFound; // is user in table? //********************************************************* // Step 1: Read in the password file //********************************************************* ifstream passFile("password.txt"); if (!passFile) { cout << "Unable to open 'password.txt'!" << endl; exit(0); } passFile >> tempPass.username; while (!passFile.eof() && !passwords.isFull())
  • 30. { //**add line here to insert passwords into the HashTbl passFile >> tempPass.password; } cout << "Printing the hash table:..." << endl; //**add line here to show (print) the HashTbl //********************************************************* // Step 2: Prompt for a Login and Password and check if valid //********************************************************* cout << "Login: "; while (cin >> name) // to quit, type CTRL Z in Visual C++ { //**add line here to retrieve user from HashTbl cout << "Password: "; cin >> pass; //**add lines here to compare retrieved user password to //**input password and print "Authentication failure" //**or "Authentication successful" cout << "Login: "; } cout << endl; }