Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Design an efficient algorithm that achieves the following task: IN JAVA Given a link list of n floating-point numbers, it returns a two-dimensional link

Design an efficient algorithm that achieves the following task: IN JAVA
 

Given a link list of n floating-point numbers, it returns a two-dimensional link list, say M, of size n × n in which the entry M[i][j] for i ≤ j contains the average of the array entries A[i] through A[j].

That is: if i ≤ j, then M[i][j] = (A[i] + · · · + A[j])/( j − i + 1) , whereas for i > j we have that M[i][j] = 0.

Describe the algorithm that creates this matrix in pseudocode.

What is the running time of your algorithm concerning the link list size n?

Implement the algorithm in Java.

Measure the running time of your Java program for random inputs of size n = 10, 11, 12, etc.  

Does the growth of the running time correspond to your estimates?

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

Algorithm Design And Applications

Authors: Michael T. Goodrich, Roberto Tamassia

1st Edition

1118335910, 978-1118335918

More Books

Students also viewed these Programming questions

Question

Do I make impulse purchases during my surfing sessions?

Answered: 1 week ago

Question

Determine miller indices of plane X z 2/3 90% a/3

Answered: 1 week ago

Question

What have you learned about sleep that you could apply to yourself?

Answered: 1 week ago