Engineering
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

answer
Answers: 1

Other questions on the subject: Engineering

image
Engineering, 04.07.2019 18:10, Larkinlover703
Items are similar to the free issue items, but their access is limited. (clo5) a)-bin stock items free issue b)-bin stock controlled issue c)-critical or insurance spares d)-rebuildable spares e)-consumables
Answers: 1
image
Engineering, 04.07.2019 19:10, Calliedevore
The proportional limit is always greater than the yield strength for a material. a)-trune b)- false
Answers: 3
image
Engineering, 04.07.2019 19:20, ameliaxbowen7
List 3 options on how to reduce knocking problens during engine process,
Answers: 2
image
Engineering, 04.07.2019 19:20, diawia
Air at a pressure of 1atm and a temperature of 40 c is in parallel flow over the top surface of a flat plate that is heated to a uniform temperature of 120 c. the plate has a length of 0.40m (in the flow direction) and a width of 0.15m. the reynolds number based on the plate length is 50, 000. what is the rate of heat transfer from the plate to the air? if the free stream velocity of the air is doubled and the pressure is increased to 10 atm what is the rate of heat transfer?
Answers: 2
Do you know the correct 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:

Konu
Mathematics, 27.11.2021 06:50
Konu
Health, 27.11.2021 06:50