What could be the recurrence relation that function_? The Next CEO of Stack OverflowSolving recurrence relation of algorithm complexity?Help with find recurrence relation running time.Recurrence Relation - Merge SortHow to extract fraction from a floating point numberHow could we prove the correctness of the algorithm?How to compare times?Divide and Conquer Recurrence RelationWhat could be the loop invariant for the following algorithm (addition of natural numbers)Solving recurrence relation with multiple variablesAlgorithm for returning a matrix that is the sum of the previous matrix
Could you use a laser beam as a modulated carrier wave for radio signal?
Oldie but Goldie
Is it possible to make a 9x9 table fit within the default margins?
Can you teleport closer to a creature you are Frightened of?
Is it reasonable to ask other researchers to send me their previous grant applications?
Why was Sir Cadogan fired?
Planeswalker Ability and Death Timing
What is the difference between 'contrib' and 'non-free' packages repositories?
Can a PhD from a non-TU9 German university become a professor in a TU9 university?
Advance Calculus Limit question
Why do we say “un seul M” and not “une seule M” even though M is a “consonne”?
How exploitable/balanced is this homebrew spell: Spell Permanency?
Another proof that dividing by 0 does not exist -- is it right?
Does Germany produce more waste than the US?
How should I connect my cat5 cable to connectors having an orange-green line?
Avoiding the "not like other girls" trope?
Is the offspring between a demon and a celestial possible? If so what is it called and is it in a book somewhere?
pgfplots: How to draw a tangent graph below two others?
Upgrading From a 9 Speed Sora Derailleur?
What steps are necessary to read a Modern SSD in Medieval Europe?
How to pronounce fünf in 45
Is it OK to decorate a log book cover?
Compensation for working overtime on Saturdays
Is this a new Fibonacci Identity?
What could be the recurrence relation that function_?
The Next CEO of Stack OverflowSolving recurrence relation of algorithm complexity?Help with find recurrence relation running time.Recurrence Relation - Merge SortHow to extract fraction from a floating point numberHow could we prove the correctness of the algorithm?How to compare times?Divide and Conquer Recurrence RelationWhat could be the loop invariant for the following algorithm (addition of natural numbers)Solving recurrence relation with multiple variablesAlgorithm for returning a matrix that is the sum of the previous matrix
$begingroup$
float aFunc(nyArray, n)
if ( (n==1)
return nyArray[0];
// let nyArray1,nyArray2,nyArray3,nyArray4 be predefined arrarys
for (i= 0; i<= (n/2) -1 ; i++)
for (j =0; j<= (n/2)-1 ; i++)
nyArray1[i]= nyArray[i];
nyArray2[i]= nyArray[i+j];
nyArray3[i]= nyArray[n/2+j];
nyArray4[i]= nyArray[j];
x1 = aFunc(nyArray1,n/2);
x2 = aFunc(nyArray2,n/2);
x3 = aFunc(nyArray3,n/2);
x4 = aFunc(nyArray4,n/2);
return x1*x2*x3*x4;
I guess that its something like that, but Im not suce.
T(n) = 4T(n/2)+........
complex-analysis algorithms
New contributor
$endgroup$
add a comment |
$begingroup$
float aFunc(nyArray, n)
if ( (n==1)
return nyArray[0];
// let nyArray1,nyArray2,nyArray3,nyArray4 be predefined arrarys
for (i= 0; i<= (n/2) -1 ; i++)
for (j =0; j<= (n/2)-1 ; i++)
nyArray1[i]= nyArray[i];
nyArray2[i]= nyArray[i+j];
nyArray3[i]= nyArray[n/2+j];
nyArray4[i]= nyArray[j];
x1 = aFunc(nyArray1,n/2);
x2 = aFunc(nyArray2,n/2);
x3 = aFunc(nyArray3,n/2);
x4 = aFunc(nyArray4,n/2);
return x1*x2*x3*x4;
I guess that its something like that, but Im not suce.
T(n) = 4T(n/2)+........
complex-analysis algorithms
New contributor
$endgroup$
add a comment |
$begingroup$
float aFunc(nyArray, n)
if ( (n==1)
return nyArray[0];
// let nyArray1,nyArray2,nyArray3,nyArray4 be predefined arrarys
for (i= 0; i<= (n/2) -1 ; i++)
for (j =0; j<= (n/2)-1 ; i++)
nyArray1[i]= nyArray[i];
nyArray2[i]= nyArray[i+j];
nyArray3[i]= nyArray[n/2+j];
nyArray4[i]= nyArray[j];
x1 = aFunc(nyArray1,n/2);
x2 = aFunc(nyArray2,n/2);
x3 = aFunc(nyArray3,n/2);
x4 = aFunc(nyArray4,n/2);
return x1*x2*x3*x4;
I guess that its something like that, but Im not suce.
T(n) = 4T(n/2)+........
complex-analysis algorithms
New contributor
$endgroup$
float aFunc(nyArray, n)
if ( (n==1)
return nyArray[0];
// let nyArray1,nyArray2,nyArray3,nyArray4 be predefined arrarys
for (i= 0; i<= (n/2) -1 ; i++)
for (j =0; j<= (n/2)-1 ; i++)
nyArray1[i]= nyArray[i];
nyArray2[i]= nyArray[i+j];
nyArray3[i]= nyArray[n/2+j];
nyArray4[i]= nyArray[j];
x1 = aFunc(nyArray1,n/2);
x2 = aFunc(nyArray2,n/2);
x3 = aFunc(nyArray3,n/2);
x4 = aFunc(nyArray4,n/2);
return x1*x2*x3*x4;
I guess that its something like that, but Im not suce.
T(n) = 4T(n/2)+........
complex-analysis algorithms
complex-analysis algorithms
New contributor
New contributor
New contributor
asked Mar 28 at 10:54
Harlinton Palacios MosqueraHarlinton Palacios Mosquera
1
1
New contributor
New contributor
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
$begingroup$
You are right about your equation.
First, let's evaluate the for-loops. The for-loop are nested and run (n/2)-1
times each. Therefore, the run time of the for-loops is ((n/2)-1)^2
. We will define this as the function f(n)=((n/2)-1)^2
.
The program function is recursively called for times with n/2
as its input. We can now describe the recurrence by the following equation:
T(n)=4T(n/2)+((n/2)-1)^2
This form of equation can be evaluated using the master's theorem. According to the definition of the master's theorem, we use case 2, because n^(log_b(a))=n^(log_2(4))=n^2=Theta(f(n))
, which is our test case. The variable a
if found by the constant times the recursive function and the variable b
is found in the divisor within the recursive call.
By the definition of case 2, the resulting complexity of your algorithm is Theta(n^(log_b(a))*log_2(n))=Theta(n^(log_2(4))*log_2(n))=Theta(n^2*log_2(n))
.
New contributor
$endgroup$
$begingroup$
Thank you for your feedback, if run time of the for-loops is ((n/2)-1)^2 and the function is f(n)=((n/2)-1)^2. The T(n) with recursive function time should be T(n)= T(n)=4T(n/2)+((n/2)-1)^2 ?
$endgroup$
– Harlinton Palacios Mosquera
Mar 28 at 12:19
$begingroup$
Yes, you are right! I will update it. Also, note I changed the result from using case 1 to use case 2 because of the mistake.
$endgroup$
– Martin Pekár
Mar 28 at 19:56
$begingroup$
Thank you so much.
$endgroup$
– Harlinton Palacios Mosquera
Mar 29 at 8:27
add a comment |
StackExchange.ifUsing("editor", function ()
return StackExchange.using("mathjaxEditing", function ()
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
);
);
, "mathjax-editing");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "69"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
noCode: true, onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Harlinton Palacios Mosquera is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3165736%2fwhat-could-be-the-recurrence-relation-that-function%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
You are right about your equation.
First, let's evaluate the for-loops. The for-loop are nested and run (n/2)-1
times each. Therefore, the run time of the for-loops is ((n/2)-1)^2
. We will define this as the function f(n)=((n/2)-1)^2
.
The program function is recursively called for times with n/2
as its input. We can now describe the recurrence by the following equation:
T(n)=4T(n/2)+((n/2)-1)^2
This form of equation can be evaluated using the master's theorem. According to the definition of the master's theorem, we use case 2, because n^(log_b(a))=n^(log_2(4))=n^2=Theta(f(n))
, which is our test case. The variable a
if found by the constant times the recursive function and the variable b
is found in the divisor within the recursive call.
By the definition of case 2, the resulting complexity of your algorithm is Theta(n^(log_b(a))*log_2(n))=Theta(n^(log_2(4))*log_2(n))=Theta(n^2*log_2(n))
.
New contributor
$endgroup$
$begingroup$
Thank you for your feedback, if run time of the for-loops is ((n/2)-1)^2 and the function is f(n)=((n/2)-1)^2. The T(n) with recursive function time should be T(n)= T(n)=4T(n/2)+((n/2)-1)^2 ?
$endgroup$
– Harlinton Palacios Mosquera
Mar 28 at 12:19
$begingroup$
Yes, you are right! I will update it. Also, note I changed the result from using case 1 to use case 2 because of the mistake.
$endgroup$
– Martin Pekár
Mar 28 at 19:56
$begingroup$
Thank you so much.
$endgroup$
– Harlinton Palacios Mosquera
Mar 29 at 8:27
add a comment |
$begingroup$
You are right about your equation.
First, let's evaluate the for-loops. The for-loop are nested and run (n/2)-1
times each. Therefore, the run time of the for-loops is ((n/2)-1)^2
. We will define this as the function f(n)=((n/2)-1)^2
.
The program function is recursively called for times with n/2
as its input. We can now describe the recurrence by the following equation:
T(n)=4T(n/2)+((n/2)-1)^2
This form of equation can be evaluated using the master's theorem. According to the definition of the master's theorem, we use case 2, because n^(log_b(a))=n^(log_2(4))=n^2=Theta(f(n))
, which is our test case. The variable a
if found by the constant times the recursive function and the variable b
is found in the divisor within the recursive call.
By the definition of case 2, the resulting complexity of your algorithm is Theta(n^(log_b(a))*log_2(n))=Theta(n^(log_2(4))*log_2(n))=Theta(n^2*log_2(n))
.
New contributor
$endgroup$
$begingroup$
Thank you for your feedback, if run time of the for-loops is ((n/2)-1)^2 and the function is f(n)=((n/2)-1)^2. The T(n) with recursive function time should be T(n)= T(n)=4T(n/2)+((n/2)-1)^2 ?
$endgroup$
– Harlinton Palacios Mosquera
Mar 28 at 12:19
$begingroup$
Yes, you are right! I will update it. Also, note I changed the result from using case 1 to use case 2 because of the mistake.
$endgroup$
– Martin Pekár
Mar 28 at 19:56
$begingroup$
Thank you so much.
$endgroup$
– Harlinton Palacios Mosquera
Mar 29 at 8:27
add a comment |
$begingroup$
You are right about your equation.
First, let's evaluate the for-loops. The for-loop are nested and run (n/2)-1
times each. Therefore, the run time of the for-loops is ((n/2)-1)^2
. We will define this as the function f(n)=((n/2)-1)^2
.
The program function is recursively called for times with n/2
as its input. We can now describe the recurrence by the following equation:
T(n)=4T(n/2)+((n/2)-1)^2
This form of equation can be evaluated using the master's theorem. According to the definition of the master's theorem, we use case 2, because n^(log_b(a))=n^(log_2(4))=n^2=Theta(f(n))
, which is our test case. The variable a
if found by the constant times the recursive function and the variable b
is found in the divisor within the recursive call.
By the definition of case 2, the resulting complexity of your algorithm is Theta(n^(log_b(a))*log_2(n))=Theta(n^(log_2(4))*log_2(n))=Theta(n^2*log_2(n))
.
New contributor
$endgroup$
You are right about your equation.
First, let's evaluate the for-loops. The for-loop are nested and run (n/2)-1
times each. Therefore, the run time of the for-loops is ((n/2)-1)^2
. We will define this as the function f(n)=((n/2)-1)^2
.
The program function is recursively called for times with n/2
as its input. We can now describe the recurrence by the following equation:
T(n)=4T(n/2)+((n/2)-1)^2
This form of equation can be evaluated using the master's theorem. According to the definition of the master's theorem, we use case 2, because n^(log_b(a))=n^(log_2(4))=n^2=Theta(f(n))
, which is our test case. The variable a
if found by the constant times the recursive function and the variable b
is found in the divisor within the recursive call.
By the definition of case 2, the resulting complexity of your algorithm is Theta(n^(log_b(a))*log_2(n))=Theta(n^(log_2(4))*log_2(n))=Theta(n^2*log_2(n))
.
New contributor
edited Mar 28 at 19:55
New contributor
answered Mar 28 at 11:18
Martin PekárMartin Pekár
11
11
New contributor
New contributor
$begingroup$
Thank you for your feedback, if run time of the for-loops is ((n/2)-1)^2 and the function is f(n)=((n/2)-1)^2. The T(n) with recursive function time should be T(n)= T(n)=4T(n/2)+((n/2)-1)^2 ?
$endgroup$
– Harlinton Palacios Mosquera
Mar 28 at 12:19
$begingroup$
Yes, you are right! I will update it. Also, note I changed the result from using case 1 to use case 2 because of the mistake.
$endgroup$
– Martin Pekár
Mar 28 at 19:56
$begingroup$
Thank you so much.
$endgroup$
– Harlinton Palacios Mosquera
Mar 29 at 8:27
add a comment |
$begingroup$
Thank you for your feedback, if run time of the for-loops is ((n/2)-1)^2 and the function is f(n)=((n/2)-1)^2. The T(n) with recursive function time should be T(n)= T(n)=4T(n/2)+((n/2)-1)^2 ?
$endgroup$
– Harlinton Palacios Mosquera
Mar 28 at 12:19
$begingroup$
Yes, you are right! I will update it. Also, note I changed the result from using case 1 to use case 2 because of the mistake.
$endgroup$
– Martin Pekár
Mar 28 at 19:56
$begingroup$
Thank you so much.
$endgroup$
– Harlinton Palacios Mosquera
Mar 29 at 8:27
$begingroup$
Thank you for your feedback, if run time of the for-loops is ((n/2)-1)^2 and the function is f(n)=((n/2)-1)^2. The T(n) with recursive function time should be T(n)= T(n)=4T(n/2)+((n/2)-1)^2 ?
$endgroup$
– Harlinton Palacios Mosquera
Mar 28 at 12:19
$begingroup$
Thank you for your feedback, if run time of the for-loops is ((n/2)-1)^2 and the function is f(n)=((n/2)-1)^2. The T(n) with recursive function time should be T(n)= T(n)=4T(n/2)+((n/2)-1)^2 ?
$endgroup$
– Harlinton Palacios Mosquera
Mar 28 at 12:19
$begingroup$
Yes, you are right! I will update it. Also, note I changed the result from using case 1 to use case 2 because of the mistake.
$endgroup$
– Martin Pekár
Mar 28 at 19:56
$begingroup$
Yes, you are right! I will update it. Also, note I changed the result from using case 1 to use case 2 because of the mistake.
$endgroup$
– Martin Pekár
Mar 28 at 19:56
$begingroup$
Thank you so much.
$endgroup$
– Harlinton Palacios Mosquera
Mar 29 at 8:27
$begingroup$
Thank you so much.
$endgroup$
– Harlinton Palacios Mosquera
Mar 29 at 8:27
add a comment |
Harlinton Palacios Mosquera is a new contributor. Be nice, and check out our Code of Conduct.
Harlinton Palacios Mosquera is a new contributor. Be nice, and check out our Code of Conduct.
Harlinton Palacios Mosquera is a new contributor. Be nice, and check out our Code of Conduct.
Harlinton Palacios Mosquera is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Mathematics Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3165736%2fwhat-could-be-the-recurrence-relation-that-function%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown