Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1) Consider the following segment of pseudocode: ,a, input: a positive integer n and a sequence of n numbers a,,a, output: count, P count=0 P:=1

image text in transcribed

1) Consider the following segment of pseudocode: ,a, input: a positive integer n and a sequence of n numbers a,,a, output: count, P count=0 P:=1 for i:=1 to n if (a; > 0) count := count +1 P:=P* a; end-if end-for return (count, P) a) Explain in a single sentence what this algorithm does. That is, for any valid input, what does the final value of P mean? Walk through the pseudocode for this algorithm indicating the final values of the three variables count and P for each of the three sets of data: b) n= 5 a,,a,,a, = 1, 2, 3, 4, 5 c)n = 10 4,,,, ,a, = 3, 5, -3, 4, 0, -2, 6, -5, -7,2 d) n=8 a,,a,',a, = 0, -45, 0, 0, -79, -25, 0, -160

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

Inference Control In Statistical Databases From Theory To Practice Lncs 2316

Authors: Josep Domingo-Ferrer

2002nd Edition

3540436146, 978-3540436140

Students also viewed these Databases questions