Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The runtime of many recursive algorithms takes the following form: T ( 1 ) = O ( 1 ) , T ( n ) =
The runtime of many recursive algorithms takes the following form: where is the runtime of the function on an input of size and and are constants and that do not depend on a What do and represent in terms of the structure of the algorithm? b We can represent the structure of a recursive algorithm with runtime : using a tree: Each dot represents a call to the recursive function vdots vdots When you get to small enough inputs, hit the base case, and no further recursive calls. Base cases are the leaves of the tree. Each call to the algorithm is represented by a vertex, the initial call of the function is the root, and each recursive call produces a child vertex from the vertex of the function that called it In terms of the original input size andor how many levels will this tree have from the root to the leaves In other words, how many levels of recursion will there be c In terms of andor how many function calls are there at the th level of recursion? In terms of the tree, we can rephrase this question as how many vertices are there in level below the root? d At each level of recursion, the size of the input to the function decreases. If the original call had an input of size in terms of andor what is the size of the input to the function calls at level e In terms of the original input size andor at a single vertex function call at level how much time how many operations is used by that function call, excluding any operations done in the recursive calls it makes. For example, in MergeSort, if the input to a function call is size the work done at that call and ignoring the two recursive calls is because we only look at nonrecursive parts of the algorithm, which take time f In terms of the original input size andor how much time how many operations is used by all function calls at level excluding any operations done by the further recursive calls they make? Combine your answers to c and e g In terms of the original input size andor how much time how many operations is used by all function calls in the algorithm at all levels of recursionPlease leave in summation notation.h Use the formula for geometric series: to evaluate the sum from the previous question. i If what is the bigO runtime of the algorithm? You should assume and are constants, and is the variable that gets large. j If what is the bigO runtime of the algorithm? You should assume and are constants, and is the variable that gets large. k If what is the bigO runtime of the algorithm? You should assume and are constants, and is the variable that gets large. You should find that the runtime behaves differently depending on the possible relationships between and Qualitatively explain the behavior in each case. I'll do one case as an example: if that means that a tends to be small relative to and If and are large, that means
The runtime of many recursive algorithms takes the following form:
where is the runtime of the function on an input of size and and are constants and that
do not depend on
a What do and represent in terms of the structure of the algorithm?
b We can represent the structure of a recursive algorithm with runtime :
using a tree:
Each dot represents a call
to the recursive function
vdots
vdots
When you get to small enough inputs, hit the base case, and no
further recursive calls. Base cases are the leaves of the tree. Each call to the algorithm is represented by a vertex, the initial call of the function is the root,
and each recursive call produces a child vertex from the vertex of the function that called it In
terms of the original input size andor how many levels will this tree have from the
root to the leaves In other words, how many levels of recursion will there be
c In terms of andor how many function calls are there at the th level of recursion? In
terms of the tree, we can rephrase this question as how many vertices are there in level below
the root?
d At each level of recursion, the size of the input to the function decreases. If the original call had
an input of size in terms of andor what is the size of the input to the function
calls at level
e In terms of the original input size andor at a single vertex function call at level
how much time how many operations is used by that function call, excluding any operations
done in the recursive calls it makes. For example, in MergeSort, if the input to a function call is
size the work done at that call and ignoring the two recursive calls is because we only
look at nonrecursive parts of the algorithm, which take time
f In terms of the original input size andor how much time how many operations
is used by all function calls at level excluding any operations done by the further recursive
calls they make? Combine your answers to c and e
g In terms of the original input size andor how much time how many operations is
used by all function calls in the algorithm at all levels of recursionPlease leave in summation
notation.h Use the formula for geometric series:
to evaluate the sum from the previous question.
i If what is the bigO runtime of the algorithm? You should assume and are
constants, and is the variable that gets large.
j If what is the bigO runtime of the algorithm? You should assume and are
constants, and is the variable that gets large.
k If what is the bigO runtime of the algorithm? You should assume and are
constants, and is the variable that gets large.
You should find that the runtime behaves differently depending on the possible relationships
between and Qualitatively explain the behavior in each case. I'll do one case as an example:
if that means that a tends to be small relative to and If and are large, that means
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started