https://github.com/sayedmoataz/algorithm_phonenum_problem
Phone Numbers Updated on Jun 1, 2020 You’re the manager for the phone company on board a new space station, and you’re trying to assign numbers to various services. To increase dialing speed, you want a call to be placed as soon as a valid number is dialed. For example, if 911 is the number for emergency services, then entering those three digits starts the call immediately, so you can’t assign the number 9113 to some other service, since anyone trying to dial it would end up calling 911. There are n phone services. You have statistics for each service from other space stations; you know that the ith service is used on average fi times per year. Given f1, . . . , fn, you want to assign phone numbers to the services (using only the digits 0–9) so that services which are used more often will have shorter numbers. In particular, you want to minimize the average number of digits dialed (with the average taken over all calls to a phone service). Devise and implement an efficient algorithm for this problem. Input: Number of services N : s1,s2, … , sn Frequency of services f1, f2, …, fn Output: Phone numbers ↔ services (where services which are used most often will have shorter phone numbers)
https://github.com/sayedmoataz/algorithm_phonenum_problem
Last synced: 7 months ago
JSON representation
Phone Numbers Updated on Jun 1, 2020 You’re the manager for the phone company on board a new space station, and you’re trying to assign numbers to various services. To increase dialing speed, you want a call to be placed as soon as a valid number is dialed. For example, if 911 is the number for emergency services, then entering those three digits starts the call immediately, so you can’t assign the number 9113 to some other service, since anyone trying to dial it would end up calling 911. There are n phone services. You have statistics for each service from other space stations; you know that the ith service is used on average fi times per year. Given f1, . . . , fn, you want to assign phone numbers to the services (using only the digits 0–9) so that services which are used more often will have shorter numbers. In particular, you want to minimize the average number of digits dialed (with the average taken over all calls to a phone service). Devise and implement an efficient algorithm for this problem. Input: Number of services N : s1,s2, … , sn Frequency of services f1, f2, …, fn Output: Phone numbers ↔ services (where services which are used most often will have shorter phone numbers)
- Host: GitHub
- URL: https://github.com/sayedmoataz/algorithm_phonenum_problem
- Owner: sayedmoataz
- Created: 2021-02-15T18:25:58.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2021-08-05T21:51:04.000Z (almost 5 years ago)
- Last Synced: 2025-03-14T07:41:45.419Z (about 1 year ago)
- Language: C
- Size: 686 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Emergency Phone Numbers
You’re the manager for the phone company on board a new space station,
and you’re trying to assign numbers to various services.
To increase dialing speed, you want a call to be placed as soon as a valid number is dialed.
For example,
if 911 is the number for emergency services
then entering those three digits starts the call immediately,
so you can’t assign the number 9113 to some other service,
since anyone trying to dial it would end up calling 911.
There are n phone services.
You have statistics for each service from other space stations;
you know that the ith service is used on average fi times per year. Given f1, . . . , fn,
you want to assign phone numbers to the services (using only the digits 0–9)
so that services which are used more often will have shorter numbers.
In particular, you want to minimize the average number of digits dialed (with the average taken over all calls to a phone service).
Devise and implement an efficient algorithm for this problem.
Input: Number of services N : s1,s2, … , sn
Frequency of services f1, f2, …, fn
Output: Phone numbers ↔ services
(where services which are used most often will have shorter phone numbers)