12. (10 pts) Consider the code below: (I cut out some pieces for brevity) Commen
ID: 3915954 • Letter: 1
Question
12. (10 pts) Consider the code below: (I cut out some pieces for brevity) Comment each of the groups of code above the blank line. Looking for 1 - 3 sentence descriptions, so include as much detail as you can. No need to comment each line, don't care, want to know what the code does collectively StartoELoop 004019B6 8B 45 F8 004019B9 83 CO 01 004019BC 89 45 F8 mov add mov eax, [ebp-8] eax, 1 [ebp-8], eax ; (1 pt) 004019BF 8B 4D F8 004019C2 3B 4D 0C 004019C5 7D 36 mov ??? jge ecx, [ebp-8] ecx, [ebp+0Ch] EXIT (3 pts) 004019CD OF BE 02 004019D6 OF BE 11 004019D9 33 C2 004019E1 88 01 movsxeax, byte ptr [edx] vsx edx, byte ptr [ecx] xoI eax, edx mov [ecx], al ; (3 pts) 004019EC 8B 45 FC 004019EF 3B 45 14 004019F2 75 07 004019F4 C7 45 FC 00 00 00 00 mov [ebp-4],0 mov ??? jnz eax, [ebp-4] eax, [ebp+14h] 0x4019FB : (3 pts) 004019FB EB B9 jmp StartofLoop : (O pts) iumps to beginning of loo 2017 01-CS 3843 Computer Organization-Exam #2 Page 3Explanation / Answer
Answer
Anonymous
Anonymous answered this
Was this answer helpful?
74 answers
A)
1) Sort the sequence using Merge/Quick sort algorithm which has O(nlogn) complexity.
2) Now you have the sorted array say S[1...n], winner=S[1], count=1, maxVote=1
3) for i= 2 to n
{
while(S[i-1] == S[i])
{
count++
i++
}
if(count>maxVote)
{
maxVote=count
winner=S[i-1]
}
count=1
i++
}
4) print winner
4th step will take O(n) time because the inner(while) loop is affecting the outer(for) loop's deriving variable i.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.