95%(19)18 out of 19 people found this document helpful
This preview shows page 2 - 4 out of 9 pages.
3. (20 level)Searching for VirusesSherlock Holmes is trying to write a computer antivirus program. He starts by modeling his problem. Hethinks of computer RAM as being a binary strings2of lengthm. He thinks of a virus as being a binary strings1of lengthn<m. His program needs to find all occurrences ofs1ins2in order to get rid of the virus. Evenworse, though, these viruses are still damaging if they differ slightly froms1. So he wants to find all copiesofs1ins2that differ in at mostklocations for arbitraryk≤n.a) Give aO(mn)time algorithm for this problem.CS 170, Fall 2016, HW 22
b) Give aO(mlogm)time algorithm for anyk.(Hint: find a way to use FFT.)For this question we will not require a 4-part solution. Instead, please give us a clear description of thealgorithm and an analysis of the running time. Give Pseudocode if you feel it will enhance your solution,but it is not required.