" /> Naive Algorithm - Essay Writing Pros

# Naive Algorithm

1. Consider the following polynomial with n terms, where ai is the ith coefficient:

P (x) = n−1∑ i=0

Don't use plagiarized sources. Get Your Custom Essay on
Naive Algorithm
Just from \$13/Page

aix i = a0 + a1x+ a2x

2 + …+ an−1x n−1

Below is pseudocode of a naive algorithm that calculates P (x) for some input x:

1 Function pow(x, i): 2 // x is a number, i is an integer, returns xi

3 exp := 1 4 p := 1 5 while p ≤ i do 6 exp = exp ∗ x 7 p += 1

8 return exp

9 Function calculatePoly1(x, a, n): 10 // x is a number, a is a list of numbers, n is the length of a 11 sum := 0 12 i := 0 13 while i < n do 14 sum += a[i] * pow(x, i) 15 i += 1

16 return sum

(a) (4 points) Prove a tight bound for the runtime complexity of calculatePoly1 using sum- mations.

(b) (4 points) Give a tight bound for the space complexity of calculatePoly1. Explain your bound.

Assume that all integers and floats require the same, constant amount of memory.

Note: Unless otherwise specified, we ignore the space required to store the input argu- ments, since this will remain the same for all algorithms that solve the same problem.

(c) (10 points) Propose an algorithm calculatePoly2 with asymptotically better runtime compared to calculatePoly1 and provide its pseudocode.

Give tight bounds for your algorithm’s runtime and space complexity. Explain your bounds.

Your answer may not use a built-in exponentiation operator (like xˆn or x**n). You may use other basic operators like addition, multiplication, etc.

(a) (4 points) If an algorithm’s best case runtime is Θ(n), is it possible that it takes Θ(n2) time on some inputs?

(b) (4 points) If an algorithm’s best case runtime is Θ(n), is it possible that it takes Θ(n2) time on all inputs?

(c) (4 points) If an algorithm’s worst case runtime is O(n2), is it possible that it takes o(n2) time on some inputs?

(d) (4 points) If an algorithm’s worst case runtime is O(n2), is it possible that it takes o(n2) time on all inputs?

Pages (550 words)
Approximate price: -

Why Work with Us

Top Quality and Well-Researched Papers

Our writers have been trained on how to handle papers placed by our clients. The writer must read and understand before embarking on writing the papers. In case of any issue that needs clarification, writers are encouraged to ask the client or support.

Our team comprises of the best writers and editors. We do thorough vetting during recruitment to make sure that our writers have the knowledge and experience we aspire in the team.

Free Unlimited Revisions

Our aim is to give the client the best outcome. If for some reason you are not satisfied with the wok done, you can ask the paper to be revised or rewritten. This will be done to your satisfaction with no extra charges.

Prompt Delivery and 100% Money-Back-Guarantee

We have writers who work round the clock. This helps in making sure that all our clients’ papers are delivered on time. If we have issues with the deadline, we will ask for extension. If its not possible, the money is fully refunded.

Original & Confidential

Our clients’ confidentiality is highly respected. We can never disclose our clients’ details to third parties. In the same regard, we strive to give our clients 100% original papers. We do not tolerate plagiarism from our writers.

Clients can reach us any time of the day, and any day of the week. There is a live chat, email or phone numbers to help in ease of communication.

Try it now!

## Calculate the price of your order

Total price:
\$0.00

How it works?

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Our Services

You should never be worried about your papers even in the middle of the night. Our team will work round the clock to deliver.

## Essay Writing Service

We have an able team that can deliver your work in the shortest time possible. The academic level or the type of work should never be a hindrance. Our highly competent support team is always around (24/7) to give you any assistance you may need.