Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For this question, you need to design, analyze, and implement in C + + an algorithm to read an array ( a ) of (

For this question, you need to design, analyze, and implement in C++ an algorithm to read an
array (a) of (n) int values and a value of (x) and find the p(x)n-degree polynomial.
You need to calculate the execution time for your two algorithms.
An n-degree polynomial p(x) is an equation of the form
p(x)=i=0naixi,
where x is a constant number and each ai is an integer number in an array of size n.
Your program should implement the following operations:
a. Randomly initialize n as the size of the array.
b. Randomly initialize integer values starting from 0 and store them in an array "a".
inputData(int a[], int n)
Call this function to initialize the values of array "a".
c. Randomly generate a value for x of any value.
d. Implement a simple O(n) time algorithm for computing p(x) for a particular value of x.
e. Implement a simple O(n2) time algorithm for computing p(x) for a particular value of x.
f. Print the time needed to execute each algorithm.
g. Print the value of p(x).
Requirements:
A. The program should calculate and print out the value of p(x) using two different algorithms.
The program will measure the time needed to execute the same input but using 2 different
complex algorithms. You are not allowed to use any built-in power function in designing the
algorithms.
B. Your program should perform an experimental analysis of their running times by doing the
following:
For each algorithm, choose at least 5 appropriate large values for n, where n is the input
array size, and determine how long it takes to run 2 algorithms in nanoseconds. For
example, value of , etc.).
Notes:
Try to choose large values for n to avoid an erratic timing (e.g.,0 s or there is no
clear increase in time with respect to input size).
You are required to use the same values of n for both algorithms.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

PC Magazine Guide To Client Server Databases

Authors: Joe Salemi

1st Edition

156276070X, 978-1562760700

More Books

Students also viewed these Databases questions

Question

Which personal relationships influenced you the most?

Answered: 1 week ago