Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem 2. Consider the algorithms from class for finding the maximum contiguous sum. Assume that it takes time I to execute the instruction SS +

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
Problem 2. Consider the algorithms from class for finding the maximum contiguous sum. Assume that it takes time I to execute the instruction SS + A[r] (a) i. Write a sum for exactly how much time the third algorithm (the linear algorithm) takes executing additions involving elements from the array A? Do not justify. ii. Simplify your sum. Do not justify. (b) i. Write a sum for exactly how much time the second algorithm (the quadratic algorithm) takes executing additions involving elements from the array A? Do not justify. ii. Simplify your sum. Show your work. M 0; for i = 1 to n do for j = i to n do SE 0; for k = i to j do SA S + A[k]; end for M max(M,S); end for end for M = 0; for i = 1 to n do SE 0; for j = i to n do SE S + A[j]; M + max(M,S); end for end for M = 0; St 0; for i = 1 to n do st max (S+A[i],0); M + max(M,S); end for

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

Logics For Databases And Information Systems

Authors: Jan Chomicki ,Gunter Saake

1st Edition

1461375827, 978-1461375821

More Books

Students also viewed these Databases questions

Question

AIDA model Attention Interest Desire Action

Answered: 1 week ago