# 7-1 Final Project - Portfolio and Reflection.docx - RUNNING...

• ChaoticOrder
• 11
• 100% (8) 8 out of 8 people found this document helpful

This preview shows page 1 - 5 out of 11 pages.

RUNNING HEAD: 7-1 Final Project 7-1 Final ProjectPortfolio and ReflectionBrandon RicksCS-260Gene Rodriguez M.S, MBA, PhD. CandidateSouthern New Hampshire University 06/21/2020
7-1 Final Project Final Project: Portfolio and ReflectionFor the first part of this portfolio and reflection I will discuss data structures. Data structures are the organization, management, and storage of data for easy and efficient access andmodification. The way this data is stored and accessed is based primarily on the structure it’s organized in. For this reflection, I will be going over 3 types of data structures: vectors, hash tables, and tree structures.Vectors are an organized list of a given data type. Each item in a vector is called an element. The size of a vector can be changed, expanded or contracted, based on the number of elements they contain. Vectors allocate memory dynamically, which can sometimes cause them to be slower than other structures. An example of a vector would be the Binary Search Tree from lab 2:vector<Bid>loadBids(stringcsvPath)vector<Bid>bids;// initialize the CSV Parser using the given pathcsv::Parser file=csv::Parser(csvPath);// loop to read rows of a CSV filefor(unsignedinti=0;i<file.rowCount();i++){Bidbid;bid.title=file[i][0];bid.fund=file[i][8];1
7-1 Final Project bid.amount=strToDouble(file[i][4],'\$');bids.push_back(bid);}returnbids;This snippet of code illustrates the defining of a vector, and then the code to populate a vector. Each element is assigned a new place within the vector, and given a data structure, using title, fun, and amount, and then added. This organization of data allows easy addition of information, and easy search functionality, using the data structure.Hash tables are another data structure that stores unordered items by mapping (hashing) each individual item to a location in an array (or a vector). In a hash table, and item’s key is the value used to map to an index. Ideally, every key will be unique, and allow for easy access and searching. An example of a hash table would be from lab 5-2, which focused primarily on hash tables:BidHashTable::Search(stringbidId){Bidbid;// Calculate key for bidunsignedkey=hash(atoi(bidId.c_str()));// Try retrieve of node using keyNode*node=&(nodes.at(key));// If no entry foundif(node==nullptr||node->key==UINT_MAX){2
7-1 Final Project returnbid;}// If node found matches keyif(node!=nullptr&&node->key!=UINT_MAX&&node->bid.bidId.compare(bidId)==0){returnnode->bid;}// Walk linked list for matchwhile(node!=nullptr){if(node->key!=UINT_MAX &&node->bid.bidId.compare(bidId)==0){returnnode->bid;}node=node->next;}returnbid;}This example shows a search of a hash table, by calculating the key, and attempting to retrieve the node for the key. If no key is found, it will simply return. If the key is found, it will return thebid that matches the key. It does this by walking the linked list in order to find a matching key.