subject

Make a backwards phonebook from a regular phonebook

your function should take 2 parameters: infile and outfile

infile should be a phonebook in the same format as question 2 (version 2).

outfile should be a list of phone number people pairs, sorted by phone number

as with question 2, you should account for the possibility that 2 people may share a single phone number (e. g., a land line if they live in the same home)

first read in all phone numbers into a dictionary, the same as you had done for question 2. you can call functions defined in question 2 and use global variables from question 2 as well if it makes sense to do so.

read through that dictionary and create a backwards version.

in the new dictionary the keys are phone numbers and the values are lists of people

use a similar strategy as with version 2 of question 2:

if a number is not in the dictionary, you create a new entry which is a list of a single person

otherwise, you check the list associated with that number and you add a person's name if they are not already listed in the (backwards) phonebook

create a list of keys from the dictionary and sort it.

for each key in the list, look up the corresponding entry/

for each name in the entry (also a list), write a line in the output firle consisting of a telephone number + a tab + a name

for example, given the sample file

name phone number
bob 212-888-
bugs 917-433-
daffy 914-400-4141
daffy 800-999-
daisy 914-400-4141
daisy 123-456-7890
pippi 301-999-9990
pippi 800-333-4400
yosemite 212-333-
as input, the program would produce

telephone number name
123-456-7890 daisy
212-333- yosemite
212-888- bob
301-999-9990 pippi
800-333-4400 pippi
800-999- daffy
914-400-4141 daisy
914-400-4141 daffy
917-433- bugs
as output (notice that daffy and daisy share a phone number).

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 09:00
Howard is designing a chair swing ride. the swing ropes are 5 meters long, and in full swing they tilt in an angle of 29° outside chairs to be 2.75 m above the ground in full swing.
Answers: 1
question
Computers and Technology, 22.06.2019 15:30
Melissa needs to add a topic to an email that she will send to her teacher. choose the name of the field where she should type her topic.
Answers: 2
question
Computers and Technology, 22.06.2019 18:30
Technician a says that a shop towel should never be used to clean around the flange area before replacing an automatic transmission filter. technician b says that a dimpled transmission fluid pan can be repaired. who is right
Answers: 3
question
Computers and Technology, 23.06.2019 01:10
Problem 1 - hashing we would like to use initials to locate an individual. for instance, mel should locate the person mark e. lehr. note: this is all upper case. generate a hash function for the above using the numbers on your telephone. you know, each letter has a number associated with it, so examine your telephone keypad. generate 512 random 3 letter initials and take statistics on a linked list array size 512 to hold this information report how many have no elements, 1 element, 2 elements, does this agree with the hashing statistics distribution?
Answers: 1
You know the right answer?
Make a backwards phonebook from a regular phonebook

your function should take 2 paramete...
Questions
question
Mathematics, 16.12.2021 06:40
question
World Languages, 16.12.2021 06:40
question
English, 16.12.2021 06:40
question
Mathematics, 16.12.2021 06:40
question
History, 16.12.2021 06:40
question
Engineering, 16.12.2021 06:40
question
Mathematics, 16.12.2021 06:40