The Ham Supper You're at a holiday supper where the hosts are serving far too much ham. After the supper, you're asked to take care of cleaning the dishes. However, one of your relatives tells you that the dishes can only be cleaned in the sink if their ham-ing distance is the length of the input serial number when compared with all other dishes, otherwise, they can be cleaned in the dish washer if any distance is less than the length of the serial number. A ham-ing distance is a count of the numbers that are different in the same positions. The ham-ing distance can be found by comparing the serial numbers of each of the dishes. For instance, two cups have serial numbers 0010, and 1214 meaning they have a hamming distance of 3. Therefore, they they be cleaned in the dish washer. With an additional plate that has a serial number of 3897, it would need to be cleaned in the sink as it's hamming distance is 4, or equal to the length of the serial numbers when compared to the others. The input list given with this assignment can be used to find all the serial numbers of all the dishes. Provide general code that computes, and outputs the sum of the serial numbers to be cleaned in the dish washer, and the sum of the serial numbers to be cleaned in the sink. Additionally, provide code that is specific to this input which can find the sums with a linear time complexity O(n), where n is the number of elements in the input list and with each of serial numbers having any size/length (i.e. linear time regardless of serial number size). Testing Include testing for this specialized code, as well as the generalized code. There are no specific guidelines for testing. However, they should probe edge cases, and be triggered automatically when the main function is run.
The Ham Supper You're at a holiday supper where the hosts are serving far too much ham. After the supper, you're asked to take care of cleaning the dishes. However, one of your relatives tells you that the dishes can only be cleaned in the sink if their ham-ing distance is the length of the input serial number when compared with all other dishes, otherwise, they can be cleaned in the dish washer if any distance is less than the length of the serial number. A ham-ing distance is a count of the numbers that are different in the same positions. The ham-ing distance can be found by comparing the serial numbers of each of the dishes. For instance, two cups have serial numbers 0010, and 1214 meaning they have a hamming distance of 3. Therefore, they they be cleaned in the dish washer. With an additional plate that has a serial number of 3897, it would need to be cleaned in the sink as it's hamming distance is 4, or equal to the length of the serial numbers when compared to the others. The input list given with this assignment can be used to find all the serial numbers of all the dishes. Provide general code that computes, and outputs the sum of the serial numbers to be cleaned in the dish washer, and the sum of the serial numbers to be cleaned in the sink. Additionally, provide code that is specific to this input which can find the sums with a linear time complexity O(n), where n is the number of elements in the input list and with each of serial numbers having any size/length (i.e. linear time regardless of serial number size). Testing Include testing for this specialized code, as well as the generalized code. There are no specific guidelines for testing. However, they should probe edge cases, and be triggered automatically when the main function is run.
C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter4: Selection Structures
Section: Chapter Questions
Problem 14PP
Related questions
Question
In Java
I have an input in a text file that I can't submit here. So, please use it as input.txt
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps
Recommended textbooks for you
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
Operations Research : Applications and Algorithms
Computer Science
ISBN:
9780534380588
Author:
Wayne L. Winston
Publisher:
Brooks Cole
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
Operations Research : Applications and Algorithms
Computer Science
ISBN:
9780534380588
Author:
Wayne L. Winston
Publisher:
Brooks Cole
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
Systems Architecture
Computer Science
ISBN:
9781305080195
Author:
Stephen D. Burd
Publisher:
Cengage Learning
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT