Question: using C language answer the following program question Part B: Finding fingerprint groups In this problem you are to write a program fgroups (short for

using C language answer the following program question

using C language answer the following program question Part B: Finding fingerprint

groups In this problem you are to write a program fgroups (short

for "fingerprint groups"), which when given a set of names with fingerprints

Part B: Finding fingerprint groups In this problem you are to write a program fgroups (short for "fingerprint groups"), which when given a set of names with fingerprints will identify groups of names that share a fingerprint. The real object of the exercise is to familiarize you with the CII library and with C I/O. Your input is always on standard input. Input is a sequence of lines where each line has the following format: The line begins with one or more non-whitespace characters. This sequence of characters is the fingerprint. The fingerprint is followed by one or more whitespace characters, not including newline. The name begins with the next non-whitespace character and continues through the next newline. A name may contain whitespace, but a name never contains a newline. . Finally, you may also assume that each name appears at most once. You may assume that a fingerprint is at most 512 characters long (2048 bits represented in hexadecimal notation), but there is no a priori upper bound on the length of a name. . What to do with good input By the nature of the input, every fingerprint you read will be associated with at least one name. If a fingerprint is associated with exactly one name, ignore the fingerprint (and the name) If a fingerprint is associated with two or more names, those names consti- tute a fingerprint group. A fingerprint group always has at least two members. Your program should print all the fingerprint groups in the following format: If there are no fingerprint groups, print nothing. If there is exactly one fingerprint group, print it. If there are multiple fingerprint groups, print them separated by newlines. Groups may be printed in any order. . . Groups may be printed in any order. To print a fingerprint group, print each name in the group. Put a newline after each name, as if by printf("%s ", name); 4. Names within the group may be printed in any order. For example, if the input is A A B A Ron Poppy Bill Dubya Barry Orange Joe B A B Then one possible output is Ron ILUL A B A B Poppy Bill Dubya Barry Orange Joe A B Then one possible output is Ron Dubya Poppy Orange Bill Barry Joe (This example output contains exactly one blank line.) My solution to this problem takes about 150 lines of C code. About 25 lines deal with input; about 25 lines are devoted to printing output; and about 50 lines are memory management and I/O. The actual algorithm is under 20 lines. The rest is comments, whitespace, #include directives, and the like. What to do with bad input If you get an input line that is badly formed, write an error message to stderr, discard the badly formed line, and continue. If you get a fingerprint of more than 512 characters, you may choose to write an error message to stderr, discard the line, and continue or you may handle the oversize fingerprint correctly. In other words, your program doesn't need to handle fingerprints larger than 512 characters, but you won't be penalized if it does. Your program should handle any name that can appear in the filesystem; if you get a name that is longer than you can handle, write a suitable message to stderr, truncate the name, and use the truncated name with the given fingerprint. If a name appears more than once, your program may silently give wrong answers, but it must not crash or commit memory errors. Part B: Finding fingerprint groups In this problem you are to write a program fgroups (short for "fingerprint groups"), which when given a set of names with fingerprints will identify groups of names that share a fingerprint. The real object of the exercise is to familiarize you with the CII library and with C I/O. Your input is always on standard input. Input is a sequence of lines where each line has the following format: The line begins with one or more non-whitespace characters. This sequence of characters is the fingerprint. The fingerprint is followed by one or more whitespace characters, not including newline. The name begins with the next non-whitespace character and continues through the next newline. A name may contain whitespace, but a name never contains a newline. . Finally, you may also assume that each name appears at most once. You may assume that a fingerprint is at most 512 characters long (2048 bits represented in hexadecimal notation), but there is no a priori upper bound on the length of a name. . What to do with good input By the nature of the input, every fingerprint you read will be associated with at least one name. If a fingerprint is associated with exactly one name, ignore the fingerprint (and the name) If a fingerprint is associated with two or more names, those names consti- tute a fingerprint group. A fingerprint group always has at least two members. Your program should print all the fingerprint groups in the following format: If there are no fingerprint groups, print nothing. If there is exactly one fingerprint group, print it. If there are multiple fingerprint groups, print them separated by newlines. Groups may be printed in any order. . . Groups may be printed in any order. To print a fingerprint group, print each name in the group. Put a newline after each name, as if by printf("%s ", name); 4. Names within the group may be printed in any order. For example, if the input is A A B A Ron Poppy Bill Dubya Barry Orange Joe B A B Then one possible output is Ron ILUL A B A B Poppy Bill Dubya Barry Orange Joe A B Then one possible output is Ron Dubya Poppy Orange Bill Barry Joe (This example output contains exactly one blank line.) My solution to this problem takes about 150 lines of C code. About 25 lines deal with input; about 25 lines are devoted to printing output; and about 50 lines are memory management and I/O. The actual algorithm is under 20 lines. The rest is comments, whitespace, #include directives, and the like. What to do with bad input If you get an input line that is badly formed, write an error message to stderr, discard the badly formed line, and continue. If you get a fingerprint of more than 512 characters, you may choose to write an error message to stderr, discard the line, and continue or you may handle the oversize fingerprint correctly. In other words, your program doesn't need to handle fingerprints larger than 512 characters, but you won't be penalized if it does. Your program should handle any name that can appear in the filesystem; if you get a name that is longer than you can handle, write a suitable message to stderr, truncate the name, and use the truncated name with the given fingerprint. If a name appears more than once, your program may silently give wrong answers, but it must not crash or commit memory errors

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!