Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Do it Your Self. Thank you very very much. Meiju.Video Autigers.org It's a big question with multiple sub-questions. Sorry about that. But it is not

Do it Your Self. Thank you very very much. Meiju.Video Autigers.org

image text in transcribed

It's a big question with multiple sub-questions. Sorry about that. But it is not too complicated, please do them with caution. Thanks a lot a lot....

(4. 12pts) Computational problem solving: Understanding an algorithm and its strategy by simulating it on a specific input Understand the following algorithm. Simulate it mentally on the following four inputs, and state the outputs produced (value returned) in each case: (a) A: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; (b) A: [-1,-2,-3,-4,-5,-6,-7, -8,-9,-101, ; (c) A: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], (d) A: [-1, 2,-3, 4,-5, 6, 7, -8, 9, -10] Algorithm Mystery (A:array[1. .n] of integer) sum, max: integer 1 sum=0 2 max-0 3 for i = 1 to n 4 5 sum for j = 1 to n sum = sum + A [j] if sum > max then 7 8 9 return max max = sum Output when input is array (a) above: Output when input is array (b) above: Output when input is array (c) above: Output when input is array (d) above: What does the algorithm return when the input array contains all negative integers? What does the algorithm return when the input array contains all non-negative integers

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

Optimizing Data Collection In Warzones

Authors: Aaget Aamber

1st Edition

B0CQRRFP5F, 979-8869065902

More Books

Students also viewed these Databases questions