Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 2 : Hashing MIME types are used in numerous internet protocols to associate a media type ( html , image, video . . .

Question 2: 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, e.g. 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 1: Number N of elements which make up the association table.
Line 2: Number Q of file names to be analyzed.
N following lines: One file extension per line and the corresponding MIME type (separated by a
blank space).
Q following lines: One file name per line.
Output
For each of the Q filenames, display on a line the corresponding MIME type. If there is no
corresponding type, then display UNKNOWN.
Example Input:
3
3
html text/html
png image/png
gif image/gif
animated.gif
portrait.png
index.html
Example Output:
image/gif
image/png
text/html
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

How many Tables Will Base HCMSs typically have? Why?

Answered: 1 week ago

Question

What is the process of normalization?

Answered: 1 week ago