You are given N customer data whereeach data contains AccNumber, name, age, and ballance. The givendatais sortedlexicographically ascending based on the AccNumber. Then, there are M queries For each query. gven a variable x. You are asked to tel whether a customer whose AccNumber isx exists. If so, output the customer'sdata.if the customer doesnot exist, output"-1".
You are given N customer data whereeach data contains AccNumber, name, age, and ballance. The givendatais sortedlexicographically ascending based on the AccNumber. Then, there are M queries For each query. gven a variable x. You are asked to tel whether a customer whose AccNumber isx exists. If so, output the customer'sdata.if the customer doesnot exist, output"-1".
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
PLEASE HELP SIR, USE BINARY SEARCH, THX. USING C LANGUAGE.
![+
(D Page view A Read aloud V Draw
F Highlight
O Erase
4
of 17
B. Record Finder[EN]
You are given N customer data where each data contains AccNumber, name, age, and ballance. The
given data is sorted lexicographically ascending based on the AccNumber. Then, there are M queries.
For each query, given a variable x. You are asked to tel whether a customer whose AccNumber is x
exists. If so, output the customer's data. If the customer does not exist, output"-1".
Input Format
The first line consists of an integer N.
The next N lines contain the given data. Each data consists of AccNumber, name, age, and balance,
respectively, separated by commas.
The next line consists of an integer M.
The next M lines consist of an integer x, which representeach query.
Output Format
For each query, if the customer exists, then print the data with the following format: "<Name> <Age>
<Balance with 2 decimal places>".
Ifthere is no data to display, output "-1".
Constraints
1SN,M S5 x 10
All given AccNumber and x in each query are a string consists of exactly 4 upper case Latin
alphabet characters. It is guaranteed that there are no 2 data with the same AccNumber.
• Length of the name is between 1 and 20 (inclusive). Names consist of Latin alphabets and
whitespaces. It is guaranteed that the first and last character are not whitespaces.
• Ages are between 10 and 100 (inclusive)
Balances are between 0 and 10.It is guaranteed that the balances are givenin 2 decimal places.
Subtask 1 (80 points):
• 1 SN,M S 103
Subtasks 2 (20 points):
No additional constraint
Sample Input
Sample Output](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F5a9fafeb-a8b5-4dfb-8d25-eb7afe2d8e1c%2Fb636a571-eae3-4266-970a-dc194fe06417%2F1zegabu_processed.png&w=3840&q=75)
Transcribed Image Text:+
(D Page view A Read aloud V Draw
F Highlight
O Erase
4
of 17
B. Record Finder[EN]
You are given N customer data where each data contains AccNumber, name, age, and ballance. The
given data is sorted lexicographically ascending based on the AccNumber. Then, there are M queries.
For each query, given a variable x. You are asked to tel whether a customer whose AccNumber is x
exists. If so, output the customer's data. If the customer does not exist, output"-1".
Input Format
The first line consists of an integer N.
The next N lines contain the given data. Each data consists of AccNumber, name, age, and balance,
respectively, separated by commas.
The next line consists of an integer M.
The next M lines consist of an integer x, which representeach query.
Output Format
For each query, if the customer exists, then print the data with the following format: "<Name> <Age>
<Balance with 2 decimal places>".
Ifthere is no data to display, output "-1".
Constraints
1SN,M S5 x 10
All given AccNumber and x in each query are a string consists of exactly 4 upper case Latin
alphabet characters. It is guaranteed that there are no 2 data with the same AccNumber.
• Length of the name is between 1 and 20 (inclusive). Names consist of Latin alphabets and
whitespaces. It is guaranteed that the first and last character are not whitespaces.
• Ages are between 10 and 100 (inclusive)
Balances are between 0 and 10.It is guaranteed that the balances are givenin 2 decimal places.
Subtask 1 (80 points):
• 1 SN,M S 103
Subtasks 2 (20 points):
No additional constraint
Sample Input
Sample Output

Transcribed Image Text:D Page view A Read aloud V Draw
F Highlight
O Erase
5
of 17
Frankie 16 999999999.99
ANGE ,Andrew Garfield,18,110933. 25
HAIS,Spectra Vgeist,18,2500e.ee
NERA, Frankie, 16, 999999999.99
TION,Dorot hy White, 22,0.ee
ww,Michael 1,17,100008.ee
Michael J 17 1e0eee.ee
NERA
JOLY
ww
Notes
In this problem, there are subtasks. If your solution can only solve subtask 1, then you will get 80
points. For example, yourprogram is not efficient enough such that it can solve the problem with the
constraint program 1<N,M < 103 underthe 1 second time limit, but unable to solve larger value of
N, such as N = M = 5x 10.
Note that for this problem, if your program can solve subtask 2, then the program can solve subtask 1
as well. Therefore, if your program can solve this problem within all of the constraints, then your
solution is considered correct and you will get 100 points.
+
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 3 steps with 1 images

Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON

Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education