Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Document preview thumbnail
Preview 2 out of 10 pages
Exam (elaborations)

CS 300 – Analysis & Design | Assignment 4-2 – Hash Tables |SNHU| – Pseudocode, Reflection, and Complete C++ Code| Grade A

Document preview thumbnail
Preview 2 out of 10 pages

This document covers CS 300 Assignment 4-2 and focuses on implementing a hash table to store, search, display, and remove bid records loaded from a CSV file. It includes structured pseudocode, a written reflection, and full C++ source code demonstrating hashing, collision handling with chaining, and efficient data retrieval. The assignment highlights modular design, defensive programming, and performance considerations when working with dynamic data structures.

Content preview

Assignment 4-2 Hash Tables

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

Document information

Uploaded on
December 28, 2025
Number of pages
10
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers
$14.99

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
TestbanksNerd
3.4
(18)
Sold
168
Followers
1
Items
460
Last sold
4 days ago



Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions