[SOLVED] please help me with C++ the part of the code and file are given below

I’m studying for my Computer Science class and need an explanation.

Struggling to find relevant content or pressed for time? – Don’t worry, we have a team of professionals to help you on
[SOLVED] please help me with C++ the part of the code and file are given below
Get a 15% Discount on this Paper
Order Now

If you’ve used an Android phone, you know that the Google Play Store is the central location for locating applications (Apple fans will recognize this as the App Store). For each “app” in the store there is a record that contains information such as the name, category, rating, etc. — allowing you to view an information page and decide if you want to install that app on your device.

In this assignment you you will experiment with hash functions (or invent your own!) to implement a directory of information about mobile apps.


The supplied input file in this module — googleplay.csv — contains entries for approximately 6000 applications. This is another CSV file similar to what we used in Lab #7. Each line contains information about a single app. There are 4 comma-separated fields, in this order: name, category, rating and reviews. You can assume the name field of each entry is unique to the file (this will be important for your hash function), but this is not true of any of the other three fields. The name field is a string of readable characters that can include spaces and punctuation.


Write a program that implements a hash table using any of the methods described in Chapter 18 or in class. You are free to use any hash function of your creation and any method you choose to handle hash collisions. A good place to start for a hash key is to use something about the name — the first letter? the last letter? the first three letters? (these will all work, but none are a very good choice). To handle collisions, you could chain them with a linked list on each “bucket”, or use open addressing with linear probing, for example.

A starter file — main_googleplay_starter.cpp — is provided. This file implements the framework for the hash table and reading of the file. Some functions are marked for your implementation (i.e. appFind() and appInsert()).


  • The program should ask for input of an app name (which may include spaces and punctuation) and output the details of the app, if it is found in the hash. Loop until an exit is requested (blank name, -1, etc.).
  • Your program only needs to implement the “add” and “lookup” functions, not deletes or rehashing/resizing of the table.
  • If the app is not found, output “Not found in the table” or similar.
  • This time, do not use any STL or any third-party libraries (for example, a Map) to implement the hash — it must be a hash of your own creation.
  • Do not use any hard-coded values, i.e. fixed strings that return responses to fixed questions. The program must be able to retrieve any of the keys available in the file.
  • Each entry should be hashed (some key generated, based in something about the record) i.e. do not just read the data into an array or some other fixed structure.
  • Output the average number of comparisons required to add all the entries from the file, and the number of comparisons for each successful or failed lookup.

See if you can bring down the number of comparisons from your first attempt. A little Google searching will yield some string-optimized hash functions. There is no “right” answer, but hash functions that perform very poorly (close to a linear search) will lose points.

Example Output

Read 6239 apps.
Average comparisons required: 1.78
Enter an app name (<return> to quit): Mandala Coloring Book

Found, comparisons required: 8
Name: Mandala Coloring Book
Rating: 4.6
Number of reviews: 4326

Enter an app name (<return> to quit): Monster Ride Pro

Found, comparisons required: 2
Name: Monster Ride Pro
Category: GAME
Rating: 5.0
Number of reviews: 1

Enter an app name (<return> to quit): SuperVPN Free VPN Client

Found, comparisons required: 1
Name: SuperVPN Free VPN Client
Category: TOOLS
Rating: 4.3
Number of reviews: 576454

Enter an app name (<return> to quit): Calculus with Bobby Flay

Not found in the table.
Comparisons required: 6

Enter an app name (<return> to quit):


#include <iostream>

#include <sstream>

#include <fstream>

#include <cstdlib>

using namespace std;

#define FILENAME “googleplay.csv”

// A single app in the Google Play Store. If you are using

// chaining, you may need to add an additional structure here (or a

// ‘next’ pointer within this structure) to maintain the chains in

// each bucket.

typedef struct {

string name;

string category;

double rating;

int reviews;

} googlePlayApp;

// Starting size. Don’t adjust this unless absolutely necessary.

const int HASH_SIZE = 10007;

// Hash table for all of the apps — static so it’s zeroed. This

// is an array of pointers (change as needed).

static googlePlayApp *appHash[HASH_SIZE];

// Reads a single app, filling in the

// fields (name, etc.) passed by the caller. The caller

// is expected to pass a single line (row) from the csv file.

void readSingleApp(const string &str,

googlePlayApp &newApp) {

istringstream istr(str);

string fields[5];

string tmp;

int i = 0;

// Read in each csv column

while (getline(istr, tmp, ‘,’)) {

fields[i++] = tmp;


// Populate the new item with the column info

newApp.name = fields[0];

newApp.category = fields[1];

newApp.rating = atof(fields[2].c_str());

newApp.reviews = atoi(fields[3].c_str());


// Insert a new app into the hash table. You may want to add a

// reference variable here to track number of comparisons.

void appInsert(googlePlayApp &newApp) {

// Implement this function


// Find an app in the hash table

// Returns ‘true’ if the app was found, filling in the

// fields of ‘foundApp’, else false. You may want to add a reference

// variable here to track number of comparisons.

bool appFind(const string &name, googlePlayApp &foundApp) {

// Implement this function


int main() {

ifstream inFile(FILENAME);

string inputLine, inputStr;

int linesRead = 0;

// Read in each app entry

while (getline(inFile, inputLine)) {

googlePlayApp newApp;

readSingleApp(inputLine, newApp);



// For extra debugging output

//if (linesRead % 1000 == 0)

// cout << “Inserted ” << linesRead << ” entries”

// << endl;


if (linesRead == 0) {

cerr << “Reading failed.” << endl;

return (-1);

} else {

cout << “Read ” << linesRead << ” apps.” << endl;


for (;;) {

string tmp;

googlePlayApp foundApp;

cout << “Enter an app name (<return> to quit): “;

getline(cin, tmp);

if (tmp == “”) {



if (appFind(tmp, foundApp) == false) {

cout << “Not found in the database.” << endl;



// Output the app info here

cout << “Name: ” << foundApp.name << endl;

// …


return (0);


Calculate the price
Make an order in advance and get the best price
Pages (550 words)
*Price with a welcome 15% discount applied.
Pro tip: If you want to save more money and pay the lowest price, you need to set a more extended deadline.
We know how difficult it is to be a student these days. That's why our prices are one of the most affordable on the market, and there are no hidden fees.

Instead, we offer bonuses, discounts, and free services to make your experience outstanding.
Sign up, place your order, and leave the rest to our professional paper writers in less than 2 minutes.
step 1
Upload assignment instructions
Fill out the order form and provide paper details. You can even attach screenshots or add additional instructions later. If something is not clear or missing, the writer will contact you for clarification.
Get personalized services with MyCoursebay
One writer for all your papers
You can select one writer for all your papers. This option enhances the consistency in the quality of your assignments. Select your preferred writer from the list of writers who have handledf your previous assignments
Same paper from different writers
Are you ordering the same assignment for a friend? You can get the same paper from different writers. The goal is to produce 100% unique and original papers
Copy of sources used
Our homework writers will provide you with copies of sources used on your request. Just add the option when plaing your order
What our partners say about us
We appreciate every review and are always looking for ways to grow. See what other students think about our do my paper service.
Customer 452813, June 25th, 2022
Customer 452813, June 26th, 2022
Thank you for the great job and timely delivery.
Customer 452457, December 18th, 2020
Great Work!
Customer 452587, March 10th, 2022
Criminal Justice
Great work! Followed directions to the latter.
Customer 452485, September 1st, 2021
Thank you!!!
Customer 452557, June 26th, 2021
The paper is well written and professional. I highly recommend
Customer 452485, August 22nd, 2021
IT, Web
Don did an excellent job!!!
Customer 452885, January 25th, 2023
Thank you so very much!!!
Customer 452517, May 11th, 2021
Professions and Applied Sciences
Amazing work!
Customer 452707, May 29th, 2022
Great work! Thank you so much.
Customer 452707, July 15th, 2022
Criminal law
Thank You!
Customer 452465, January 29th, 2021
15% OFF your first order
Use a coupon FIRST15 and enjoy expert help with any task at the most affordable price.
Claim my 15% OFF Order in Chat

Get top-notch homework help now. 20% off first 10 orders!


Thank you for choosing MyCoursebay. Your presence is a motivation to us. All papers are written from scratch. Plagiarism is not tolerated. Order now for a 15% discount

Order Now