Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Woriking on how to get the input in one line suh as getline() but it is not working input as AL,Mobile,195111,(30.67762486480, -88.1184482714) AK,Anchorage,291826,(61.14986873100, -149.111113424) AZ,Phoenix,1445632,(33.57241386950,

Woriking on how to get the input in one line suh as getline() but it is not working

input as

AL,Mobile,195111,"(30.67762486480, -88.1184482714)"

AK,Anchorage,291826,"(61.14986873100, -149.111113424)"

AZ,Phoenix,1445632,"(33.57241386950, -112.088995222)"

AZ,Scottsdale,217385,"(33.68724936510, -111.865085877)"

AR,Fayetteville,73580,"(36.07121173120, -94.1659600436)"

AR,Fort Smith,86209,"(35.34916926360, -94.3696317306)"

and the outppput sach as :

image text in transcribed

#include

#include

using namespace std;

class City

{

public:

string city;

string state;

string pop;

string lat;

string lon;

City()

{

cout

}

};

int hash1(string city)

{

int len = city.length();

int sum = 0;

for (int i = 0; i

{

sum += city[i];

}

return sum;

}

int hash2(string city)

{

int len = city.length();

int sum = 0;

for (int i = 0; i

{

sum += city[i] * city[i];

}

return sum;

}

void hash_display(City *arr[],int size)

{

// cout

for (int j = 0; j

{

City *city = arr[j];

if(city != NULL)

{

cout state citypoplatlon

}

else

{

cout

}

}

}

void insert(City *arr[], bool isNULL[], City *c, int size, int count)

{

// cout

int hash_value = hash1(c->city);

// cout

int i = hash_value;

bool full = false;

bool visited[size];

memset(visited, false, sizeof(visited));

// cout

while (!isNULL[i%size])

{

// cout

if (visited[i%size])

{

full = true;

break;

}

if (arr[i%size]->city == c->city)

{

cout

return;

}

cout city

i = (i + i*hash2(c->city)) % size;

if (i == hash_value)

{

cout

full = true;

break;

}

}

if (full)

{

return;

}

count++;

arr[i%size] = c;

isNULL[i%size] = false;

}

int main()

{

int size;

cout

cin >> size;

City *arr[size];

bool isNULL[size];

for (int i = 0; i

{

arr[i] = NULL;

isNULL[i] = true;

}

string cityname, state, pop, lat, lon;

string ch;

int count = 0;

do

{

cout

cin >> state >> cityname >> pop>> lat >> lon;

City *c = new City;

c->city = cityname;

c->state = state;

c->pop = pop;

c->lat = lat;

c->lon = lon;

insert(arr, isNULL, c, size, count);

cout

cin >> ch;

} while (!(ch == "InsertionEnd") && count

if(ch =="hash_display")

{

hash_display(arr, size);

}

//City c;

return 0;

}

wsc index state city name collisions population geolocation none none CO Denver DC Washington0 none none AK none (39.76202837430, -104.876365322) + (38.90992414260, -77.0147205666) none 0 600158 601723 Anchorop 91826 11:57 PM wsc index state city name collisions population geolocation none none CO Denver DC Washington0 none none AK none (39.76202837430, -104.876365322) + (38.90992414260, -77.0147205666) none 0 600158 601723 Anchorop 91826 11:57 PM

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases And Information Systems 1 International Baltic Conference Dbandis 2020 Tallinn Estonia June 19 2020 Proceedings

Authors: Tarmo Robal ,Hele-Mai Haav ,Jaan Penjam ,Raimundas Matulevicius

1st Edition

303057671X, 978-3030576714

More Books

Students also viewed these Databases questions

Question

Ensure continued excellence in people management.

Answered: 1 week ago

Question

Enhance the international team by recruiting the best people.

Answered: 1 week ago