[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.

Input

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.

Assignment

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()).

Requirements

  • 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
Category: ART_AND_DESIGN
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):

main_googleplay_starter.cpp:

#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);

appInsert(newApp);

linesRead++;

// 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 == “”) {

break;

}

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

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

continue;

}

// 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)
$0.00
*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.
s
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.
Human Resources Management (HRM)
Thank you so much. Well written paper.
Customer 452701, September 25th, 2023
Human Resources Management (HRM)
Thanks for the prompt delvery.
Customer 452701, January 20th, 2023
Other
Thank you for a well written paper!!!
Customer 452557, January 19th, 2022
Social Work and Human Services
Great Work!
Customer 452587, September 8th, 2021
Human Resources Management (HRM)
Thanks for the revision. Your support is greatly appreciated.
Customer 452701, August 27th, 2023
IT, Web
Great job on the paper.
Customer 452885, February 7th, 2023
Human Resources Management (HRM)
Thank you
Customer 452701, July 26th, 2023
Other
Great Work!
Customer 452587, March 10th, 2022
Technology
Great job on the paper!!
Customer 452885, December 14th, 2022
Wellness
The skilled writer did a great job on assignment!! Thank you!!
Customer 452547, June 16th, 2021
Other
GOOD
Customer 452813, July 5th, 2022
Nursing
Perfect as usual!!! Thanks team!
Customer 452453, May 26th, 2021
OUR GIFT TO YOU
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

Good News ! We now help with PROCTORED EXAM. Chat with a support agent for more information