eed step by step code with comment s

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

I need step by step code with comment s

 

 

Cartoons
There are N television channels available in Hungary (numbered from 1 to N) and for each of them
we know which cartoons it showed this morning. The data are given with pairs: title of a cartoon
and a channel identifier, meaning that the cartoon was shown by that channel.
Write a program that determines the following:
1.
The number of cartoons that were shown by a given channel (with identifier K).
2.
The count and list of channels that showed the cartoon which appears first in the input.
3.
The number of different channels that showed at least one cartoon.
4.
The cartoon in the input which was shown by the least channels.
5.
Two cartoons that were shown by the same number of channels.
Input
The first line of the standard input contains the number of channels (1SNS1000), the
number of data pairs (1SMS2000), and a channel identifier (1SKSN). In the next M*2 lines, there
is a data pair in every two lines: the identifier number of a channel (1SE,SN), and the title of a
cartoon which was shown by that channel. For simplicity, the titles are written in one word with at
most 10 letters of the English alphabet. A channel showed at most 10 cartoons, and the number
of different cartoons does not exceed 1000. There are no duplicate data entries (a channel cannot
show a cartoon multiple times).
Output
The standard output should contain a line with a single # character before the solution of
each subtask. This # character line is followed by as many lines as needed for the output of a
subtask. If you cannot solve a subtask, you should output only the line containing the # character.
If the output format is not correct (less/more # characters are in the output), you will get "Output
format error" even if you have correct solutions for some subtasks.
Subtask 2unit éoints): Print the number of cartoons which were shown by the channel K.
Subtask 2k pupints): The first line should contain the count of channels which showed the
the first data pair. The second line should contain the list of the identifiers of
cartoon thaon
these channels, in the same order as they appear in the input with that cartoon.
Subtask - thn
oints): Print a single number, the count of different channels that showed at least
one cartoenis
Subtask thoints): Print the cartoon that was shown by the least number of channels. In case
of multiple Bossible solutions, you must give the cartoon that is the first in their alphabetical order.
Subtask he ary coints): Print two cartoons (in any order) separated by a space, which were shown
by the sanfbe sanber of channels. If there are multiple possible solutions, give the pair of cartoons
with the most channels (among these pairs), and if there are still more than one possibilities, you
can print any of them. If there is no such pair of cartoons, print 0 0.
See the example on the next page.
Transcribed Image Text:Cartoons There are N television channels available in Hungary (numbered from 1 to N) and for each of them we know which cartoons it showed this morning. The data are given with pairs: title of a cartoon and a channel identifier, meaning that the cartoon was shown by that channel. Write a program that determines the following: 1. The number of cartoons that were shown by a given channel (with identifier K). 2. The count and list of channels that showed the cartoon which appears first in the input. 3. The number of different channels that showed at least one cartoon. 4. The cartoon in the input which was shown by the least channels. 5. Two cartoons that were shown by the same number of channels. Input The first line of the standard input contains the number of channels (1SNS1000), the number of data pairs (1SMS2000), and a channel identifier (1SKSN). In the next M*2 lines, there is a data pair in every two lines: the identifier number of a channel (1SE,SN), and the title of a cartoon which was shown by that channel. For simplicity, the titles are written in one word with at most 10 letters of the English alphabet. A channel showed at most 10 cartoons, and the number of different cartoons does not exceed 1000. There are no duplicate data entries (a channel cannot show a cartoon multiple times). Output The standard output should contain a line with a single # character before the solution of each subtask. This # character line is followed by as many lines as needed for the output of a subtask. If you cannot solve a subtask, you should output only the line containing the # character. If the output format is not correct (less/more # characters are in the output), you will get "Output format error" even if you have correct solutions for some subtasks. Subtask 2unit éoints): Print the number of cartoons which were shown by the channel K. Subtask 2k pupints): The first line should contain the count of channels which showed the the first data pair. The second line should contain the list of the identifiers of cartoon thaon these channels, in the same order as they appear in the input with that cartoon. Subtask - thn oints): Print a single number, the count of different channels that showed at least one cartoenis Subtask thoints): Print the cartoon that was shown by the least number of channels. In case of multiple Bossible solutions, you must give the cartoon that is the first in their alphabetical order. Subtask he ary coints): Print two cartoons (in any order) separated by a space, which were shown by the sanfbe sanber of channels. If there are multiple possible solutions, give the pair of cartoons with the most channels (among these pairs), and if there are still more than one possibilities, you can print any of them. If there is no such pair of cartoons, print 0 0. See the example on the next page.
Expert Solution
steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY