johnnyzags
December 15th, 2005, 05:11 PM
Hey whats up guys?? I needed some help with some homework, and I wondered if anybody could provide me the answers to these questions. Thank you.
The following Algorithm will calculate the greatest common divisor of two numbers:
GCD (M, N)
M, N are the two integers of interest
GCD returns the interger greatest common divisor
if (M < N ) then
swap M and N
end if
if ( N = 0 ) then
return M
else
quotient = M/N //Note: integer division
remainder = M mod N
return GCD ( N, remainder )
end f
Give the reucrrence relation for the number of multiplications (in this case, the division and the mod) that are done in this function.
Put the following recurrence relaiton into closed form
T(n) = 3T(n-1)-15
T(1) = 8
And the last one.. if someone could help explain to me how to..
Draw the decision tree for the binary search algorithm for a list of 12 elements. For the internal nodes of your decision tree, the node should labeled with the element checked, the left child should represent what happens if the target is less than the element checked, and the right child should represent what happens if the target is greater than the element checked.
I really appreciate the help. This is my indepdent study and I am working on this final, but i am really not too good at it at all, so any help would be greatly appreciated!
The following Algorithm will calculate the greatest common divisor of two numbers:
GCD (M, N)
M, N are the two integers of interest
GCD returns the interger greatest common divisor
if (M < N ) then
swap M and N
end if
if ( N = 0 ) then
return M
else
quotient = M/N //Note: integer division
remainder = M mod N
return GCD ( N, remainder )
end f
Give the reucrrence relation for the number of multiplications (in this case, the division and the mod) that are done in this function.
Put the following recurrence relaiton into closed form
T(n) = 3T(n-1)-15
T(1) = 8
And the last one.. if someone could help explain to me how to..
Draw the decision tree for the binary search algorithm for a list of 12 elements. For the internal nodes of your decision tree, the node should labeled with the element checked, the left child should represent what happens if the target is less than the element checked, and the right child should represent what happens if the target is greater than the element checked.
I really appreciate the help. This is my indepdent study and I am working on this final, but i am really not too good at it at all, so any help would be greatly appreciated!