Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For the following pseudo codes, find the Big-Oh notation 1) Algorithm Factorial(a): Input: An integer a Output: The value of a factorial (a!) Factorial(a) factorial

For the following pseudo codes, find the Big-Oh notation

1) Algorithm Factorial(a):

Input: An integer a

Output: The value of a factorial (a!)

Factorial(a)

factorial <-- 1

for k=1 to a do

factorial <-- factorial * k

return factorial

endAlg

2) Algorithm Power(a, b):

Input: Two integers a and b

Output: The value of a to the power b

Power(a, b)

power <-- 1

for k=1 to b do

power <-- power * a

return power

endAlg

3) Algorithm LinearSearch(A, n, q):

Input: An integer array A of size n and a query q that we wish to search the array for.

Output: The position of q in A or -1 if q is not in A

LinearSearch(A, n, q)

index <-- 0

while (index < n) and (A[index] <> q) do

index <-- index + 1

if (index = n) then

return -1

else

return index

endAlg

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

Database Machine Performance Modeling Methodologies And Evaluation Strategies Lncs 257

Authors: Francesca Cesarini ,Silvio Salza

1st Edition

3540179429, 978-3540179429

More Books

Students also viewed these Databases questions

Question

In drilling, the deeper the hole, the greater the torque. Why?

Answered: 1 week ago

Question

How do financial managers determine the value of a business?

Answered: 1 week ago