Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1.9 Lab: Airports 1 Programming language: C++ Data about airports are stored in three parallel arrays: one array contains airport codes (in ascending order), such

1.9 Lab: Airports 1

Programming language: C++

Data about airports are stored in three parallel arrays: one array contains airport codes (in ascending order), such as LAX, another array contains the names of the cities served, such as Los Angeles, and the third array contains the number of enplanements (commercial passenger boardings).

BUR 2077892 Burbank FAT 761298 Fresno LAX 39636042 Los Angeles OAK 5934639 Oakland RDD 43414 Redding SJC 5321603 San Jose SNA 5217242 Santa Ana 

Change the binary search function to search airports based on their code, then display related data as shown below:

BUR found! See related data below: Code: BUR City: Burbank Enplanements: 2077892 

or

STS not found!

HINT: Parallel arrays

These is the code to improve

// Lab: Airports 1 #include #include

using namespace std;

/* Write your code here */

int main(){ //constants definitions const int AIRPORTS = 50; // maximum size of arrays // arrays definitions string city[AIRPORTS] = {"Burbank", "Fresno", "Los Angeles", "Oakland", "Redding", "San Jose", "Santa Ana"}; string code[AIRPORTS] = {"BUR", "FAT", "LAX", "OAK", "RDD", "SJC", "SNA"}; int numOfEnpl[AIRPORTS] = {100433, 761298, 39636042, 5934639, 43414, 5321603, 5217242}; // other variables int size = 7; // actual size of arrays string target; cin >> target; // the airport code to search for /* Write your code here */ return 0; }

/* ******************************************* Definition of binary search This function performs the binary search on a string array. The array has the size of elements. A value stored in this array will be searched. It will return the array subscript if found. Otherwise, -1 will be returned. */

/* Write your code here */

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

Advanced Database Systems

Authors: Carlo Zaniolo, Stefano Ceri, Christos Faloutsos, Richard T. Snodgrass, V.S. Subrahmanian, Roberto Zicari

1st Edition

155860443X, 978-1558604438

More Books

Students also viewed these Databases questions