# Design a reasonably efficient algorithm for solving each of the following problems and determine its efficiency class.a. You are given n telephone bills and m checks sent to pay the bills (n ≥ m).Assuming that telephone numbers are written on the checks, find out who failed to pay. (For simplicity, you may also assume that only one check is written for a particular bill and that it covers the bill in full.)

Question
106 views

Design a reasonably efficient algorithm for solving each of the following problems and determine its efficiency class.

a. You are given n telephone bills and m checks sent to pay the bills (n ≥ m).
Assuming that telephone numbers are written on the checks, find out who failed to pay. (For simplicity, you may also assume that only one check is written for a particular bill and that it covers the bill in full.)

check_circle

Algorithm to find who failed to pay telephone bill

For finding who failed to pay telephone bill, first the bills and check arrays should be sorted. Then merge-like scan of these two sorted arrays is done by comparing telephone bills and telephone numbers that are written on the checks. So the detailed algorithm consists of the following steps.

Step 1: First sort bills and checks.

Step 2 : Do merge-like scan of these two sorted lists. Compare telephone numbers bi and cj and the number written on the check.

if (bi < cj) do

add bi to the list of unpaid telephone numbers

&nb...

### Want to see the full answer?

See Solution

#### Want to see this answer and more?

Solutions are written by subject experts who are available 24/7. Questions are typically answered within 1 hour.*

See Solution
*Response times may vary by subject and question.
Tagged in