subject
Engineering, 17.03.2020 22:11 courtneywick

Give a big-Oh characterization, in terms of n, of the running time of the Ex1-EX5 functions as shown in following Code Fragment ..

Algorithm
Ex1 ( A):
Input:
An array A storing n?1 integers.

Output:
The sum of the elements in A.
s? A[0]
for i?1 to n?1 do
s?s+ A[i]
return s

Algorithm
Ex2( A):
Input: An array A storing n?1 integers.
Output:
The sum of the elements at even cells in A.
s? A[0]
for i ?2 to n?1 by increments of 2 do
s?s+ A[i]
return s

Algorithm
Ex3 ( A):
Input: An array A storing n?1 integers.
Output:
The sum of the pre?x sums in A.
s?0
for i?0 to n?1 do
s?s+ A[0]
for j?1 to i do
s?s+ A[ j]
return s

Algorithm
Ex4( A):
Input:An array A storing n?1 integers.
Output:
The sum of the pre?x sums in A.
s? A[0]t ?s
for i?1 to n?1 do
s?s+ A[i]
t ?t +s
return t

Algorithm
Ex5 ( A, B):
Input:Arrays A and B each storing n?1 integers.
Output:
The number of elements in B equal to the sum of pre?x sums in A.
c?0
for i?0 to n?1 do
s ?0
for j?0 to n?1 do
s?s+ A[0]
for k ?1 to j do
s?s+ A[k ]
if B[i] =s then c?c+1
return c

ansver
Answers: 1

Other questions on the subject: Engineering

image
Engineering, 04.07.2019 18:20, karatsgrande3772
Determine the damped natural frequencies and the steady state response of a decoupled damped forced two degrees of freedom system. 10ä1 + 2q1 20q1 10 cos t; 10q2 +4q2 + 40q2 10 cos t
Answers: 3
image
Engineering, 04.07.2019 18:20, mjcbs21
What is the heat treatment of metals? what is the benefit of it? why and how it's useful? answer in details, do not write by hand.
Answers: 3
image
Engineering, 06.07.2019 03:20, loveuncondition
Not a characteristic property of ceramic material (a) high temperature stability (b) high mechanical strength (c) low elongation (d) low hardness
Answers: 2
image
Engineering, 06.07.2019 04:10, 25linm
Water flows at the rate of 200 i/s upwards through a tapered vertical pipe. the diameter at marks(3) clo5) the bottom is 240 mm and at the top 200 mm and the length is 5m. the pressure at the bottom is 8 bar, and the pressure at the topside is 7.3 bar. determine the head loss through the pipe. express it as a function of exit velocity head.
Answers: 3
You know the right answer?
Give a big-Oh characterization, in terms of n, of the running time of the Ex1-EX5 functions as shown...

Questions in other subjects: