Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Question 2 : Hashing MIME types are used in numerous internet protocols to associate a media type ( html , image, video . . .
Question : Hashing
MIME types are used in numerous internet protocols to associate a media type html image, video
with the content sent. The MIME type is generally inferred from the extension of the file to be
sent. You have to write a program that makes it possible to detect the MIME type of a file based
on its name. You are provided with a table which associates MIME types to file extensions. You
are also given a list of names of files to be transferred and for each one of these files, you must
find the MIME type to be used. The extension of a file is defined as the substring which follows
the last occurrence, if any, of the dot character within the file name. If the extension for a given
file can be found in the association table case insensitive, eg TXT is treated the same way as txt
then print the corresponding MIME type. If it is not possible to find the MIME type corresponding
to a file, or if the file doesn't have an extension, print UNKNOWN.
Input
Line : Number of elements which make up the association table.
Line : Number of file names to be analyzed.
following lines: One file extension per line and the corresponding MIME type separated by a
blank space
following lines: One file name per line.
Output
For each of the filenames, display on a line the corresponding MIME type. If there is no
corresponding type, then display UNKNOWN.
Example Input:
html texthtml
png imagepng
gif imagegif
animated.gif
portrait.png
index.html
Example Output:
imagegif
imagepng
texthtml
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started