Pseudo code
MAIN PROGRAM
Set default CSV path and bid key.
Create a new HashTable object.
Display menu until user chooses Exit:
If user selects Load Bids:
Call loadBids(csvPath, hashTable)
If user selects Display All Bids:
Call hashTable.PrintAll()
If user selects Find Bid:
Call hashTable.Search(bidKey)
Display result if found
If user selects Remove Bid:
Call hashTable.Remove(bidKey)
FUNCTION loadBids(csvPath, hashTable)
Display message indicating file load attempt.
Open CSV file using parser.
For each row in the file:
Create new Bid
Extract bidId, title, fund, and amount
Insert bid into hash table
CLASS HashTable
FUNCTION Insert(bid)
Compute key using hash(bidId)
If bucket is empty:
Store bid at bucket
Else:
Traverse linked list
Add new node at end
FUNCTION Search(bidId)
Compute key
Traverse list at bucket
If bidId matches, return bid
Else return empty bid
FUNCTION Remove(bidId)
Compute key
Traverse list to locate matching bid
If found:
Remove node and adjust links
FUNCTION PrintAll
, For each bucket:
Traverse nodes and print bid data
2. Reflection
Developing this program allowed me to deepen my understanding of how hash tables
function. Also it helped me understand how important design decisions, such as collision
handling and hashing strategy can impact performance and reliability. One of the main
challenges I encountered was ensuring that the CSV file loaded correctly, especially when
the file path was incorrect or the file was not stored in the expected directory. This
produced runtime errors from the CSV parser, which I fixed by adding a file-existence check
and improving exception handling. These issues helped me to reinforce the value of
defensive programming and the importance of validating assumptions before processing
data.
Another key part of the assignment was improving modularity and readability. Separating
the hash table operations into clearly defined methods made the code easier to understand,
debug, and reuse. Consistent naming conventions, comments, and whitespace helped keep
the logic organized and clear for future maintenance. Therefore, completing this project
strengthened my ability to design data structures in a modular way and taught me how to
debug more effectively when working with external data and dynamic memory.
3. Code
//========================================================================
====
// Name : HashTable.cpp
// Author : TESTBANKSNERD
// Version : 1.0
// Copyright : Copyright � 2023 SNHU COCE
// Description : Lab 4-2 Hash Table
//========================================================================
====
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <time.h>
#include "CSVparser.hpp"
using namespace std;
const unsigned int DEFAULT_SIZE = 179;
// Forward declaration