Question: Q: Write a method in Mips (assembly) ways that finds the number of anagrams of an input string example Input: n = 8 k =
Q:
Write a method in Mips (assembly) ways that finds the number of anagrams of an input string
example
Input:
n = 8
k = 4
s = dei
L = { abc, ide, ldc, bae, ccb, acb,ddb ,cca }
Output: 1
there is an anagram of dei in L: ide.
The algorithm should work as follows:
1. implements a mergesort to sort each string in L and store the sorted strings in the heap,
2. sorts the string s
3. checks how many sorted strings are identical to the sorted string s
4.please write the code comment if could. Many thanks.
The input parameters are provided in the following 1. a number that represents n, 2. a number that represents k, 3. the string s, and 4. the strings in L.
Many thanks.

2.data .align 2 4 k: S : .word4 # include a null character to terminate string asciiz "dei" 6 n: .word 8 7 L: .asciiz "abc" .asciiz "bae" .asciiz "ccb" .asciiz "acb" .asciiz "ddb" .asciiz "cca" asciiz "idc" .asciiz "ide" 9 10 12 13 14 15 .text 17 ### Maincode Module ### 19 ##The method to read the inputs ## 20 main: 21 li $t9,4 main: # $t9- constant 4 # $s0: length of the key word # $s1: keyword # $s2: size of string list 23 24 25 26 27 # allocate heap space for string array: 28 29 mul ao,$s2,$t9 30 31 32 # record addresses of declared strings into a string array: lw $s0,k la $s1,S lw $s2,n # syscall code 9: allocate heap space # calculate the amount of heap space syscall move $s3,$vo # $s3: base address of a string array move $to, $s2 move $t1 $s3 la $t2,L # $t0 : counter i-n # $t1: address pointer j # $t2: address of declared list L 34 35 36 READ DATA: 37 38 w $t2, (Stl) # if i >0, read string from L # put the address of a string into string array. blez $to,FIND 39 40 41 42 43 addi $to, $to,-1 addi $t1, $tl, 4 add $t2, St2, $so j READ_DATA 2.data .align 2 4 k: S : .word4 # include a null character to terminate string asciiz "dei" 6 n: .word 8 7 L: .asciiz "abc" .asciiz "bae" .asciiz "ccb" .asciiz "acb" .asciiz "ddb" .asciiz "cca" asciiz "idc" .asciiz "ide" 9 10 12 13 14 15 .text 17 ### Maincode Module ### 19 ##The method to read the inputs ## 20 main: 21 li $t9,4 main: # $t9- constant 4 # $s0: length of the key word # $s1: keyword # $s2: size of string list 23 24 25 26 27 # allocate heap space for string array: 28 29 mul ao,$s2,$t9 30 31 32 # record addresses of declared strings into a string array: lw $s0,k la $s1,S lw $s2,n # syscall code 9: allocate heap space # calculate the amount of heap space syscall move $s3,$vo # $s3: base address of a string array move $to, $s2 move $t1 $s3 la $t2,L # $t0 : counter i-n # $t1: address pointer j # $t2: address of declared list L 34 35 36 READ DATA: 37 38 w $t2, (Stl) # if i >0, read string from L # put the address of a string into string array. blez $to,FIND 39 40 41 42 43 addi $to, $to,-1 addi $t1, $tl, 4 add $t2, St2, $so j READ_DATA
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
