a)Write what each instruction does in the \"comment section. The first one is co
ID: 3602153 • Letter: A
Question
a)Write what each instruction does in the "comment section. The first one is completed for you Address nstruction X0123 X0124 0001 0010 0010 1010 X0125 X0126 X0127 0001 0010 0110 0100 X0128 0111 0010 0000 1010 X0129 Comment R, PC- 0101 0010 0110 0000 b) What is the value stored in R2 and PC at the end of execution of all the commands? Problem 5 (8 points) Give the instructions JMP, AND, LD and NOT, identify whether they are operate instructions, data movement instructions or control instructions. List all the addressing modes that can be used with the instructions mentioned above. a. b.Explanation / Answer
dna.java file
--------------------
dnaHash
public int dnaHash()
Returns the hash value of the entire string for this DNA object. Since there are only four possible characters in the strand, it uses a base 4 number system to create the hash as described in the Rabin-Karp lecture. This will be needed only to find the hash of the substring that is being searched for and the base case for finding all substring hashes in the master strand string. This should not be used to find ALL substring hashes of the master strand.
Returns: Hash of the string for this DNA object.
---------------------------------------------------------------------
charNumericValue
public static int charNumericValue(char molecule)
Given the character of a molecule, returns its numeric mapping. 'A' - 0 'C' - 1 'G' - 2 'T' - 3 Parameters: molecule - Character of molecule. Returns: Numeric mapping of passed molecule character.
---------------------------------------------------------------------
dnaSubstrand
public DNA dnaSubstrand(int pos, int length)
Generates and returns a new instance of DNA that is a substrand of this DNA. The DNA generated starts at the given position and is of the given length. Parameters: pos - Beginning of the desired substrand of DNA. length - Length of the desired substrand of DNA.
Returns: New DNA that is a substrand of this DNA.
---------------------------------------------------------------------
Seperate class file dnaMatcher.java
.
checkMatch
Given a DNA match candidate, checks if the passed DNA candidate has a longer common substring than is currently stored. Uses the Rabin-Karp algorithm for substring matching. Performs this by breaking the candidate strand into all possible substrings and sending them to the RabinKarp method. This is a bit, “Brute Force” (there are more efficient but complex ways of doing this), however the work is mitigated by eliminating many possible substrings. A substring from the candidate that is longer than master strand can be skipped. All substrings whose length is shorter than the current best match are also skipped. Additionally, substrings of the candidate are processed from longest to shortest and stops once a match is found and doesn't bother with the shorter substrings.
Parameters:
matchCandidate - Candidate for matching master strand.
---------------------------------------------------------------------------
rabinKarp
Implements Rabin-Karp alogrithm for finding longest common substring. Does the preprocessing of finding the hash for the candidate's substrand using the stringHash method and the hashes of substrings in the master strand String of the same length as the candidate substrand using the recursive RabinKarpHashes method. Uses a search to determine if the substring hash is in the collection of hashes and returns the result.
Parameters:
substrandCandidate - DNA substrand to find in the master strand.
Returns:
Location in master strand if candidate substrand is found. If not found returns -1.
---------------------------------------------------------------------------
rabinKarpHashes
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.