Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Let f ( x ) , g ( x ) be two polynomial functions given by f ( x ) = a 0 + a
Let be two polynomial functions given by cdots and cdots a pts Write an algorithm called PolyAdd in pseudocode to com pute where and are given as arrays with and The indexing goes from here instead of ; the lengths of these arrays are respectively and The result should be returned as an array which stores its coefficients, and its size b pts Analyze the running time of PolyAdd You may assume that and give your result in terms of c pts Write an algorithm PolyMult in pseudocode to compute where and are given as before. An array defining and its size should be returned. Justify the correctness of your algorithm. What loop invariant does your algorithm maintain? d pts Analyze the running time of Poly You may assume that and give your result in terms of e pts Now assume that the first input polynomial is always sparse, ie we know that will be nonzero for at most values of where is a constant. Modify the algorithm from part c to create SparsePolyMult which takes advantage of the sparsity of Write pseudocode for this algorithm or clearly note how to modify PolyMult Assuming analyze the running time of SparsePolyMult ; the running time should be
Let be two polynomial functions given by cdots
and cdots
a pts Write an algorithm called PolyAdd in pseudocode to com
pute where and are given as arrays
with and The indexing goes from here instead of ; the
lengths of these arrays are respectively and The result should
be returned as an array which stores its coefficients, and its size
b pts Analyze the running time of PolyAdd You may assume
that and give your result in terms of
c pts Write an algorithm PolyMult in pseudocode to compute
where and are given as before. An array
defining and its size should be returned. Justify the correctness of
your algorithm. What loop invariant does your algorithm maintain?
d pts Analyze the running time of Poly You may assume
that and give your result in terms of
e pts Now assume that the first input polynomial is always sparse, ie
we know that will be nonzero for at most values of where is a constant.
Modify the algorithm from part c to create SparsePolyMult which
takes advantage of the sparsity of Write pseudocode for this algorithm or
clearly note how to modify PolyMult Assuming analyze
the running time of SparsePolyMult ; the running time should be
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered 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