Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

For the following pseudo codes, find the Big-Oh notation (Show all steps)

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

Pro PowerShell For Database Developers

Authors: Bryan P Cafferky

1st Edition

1484205413, 9781484205419

More Books

Students also viewed these Databases questions

Question

ppropriate in response to employee feedback.

Answered: 1 week ago

Question

Provide examples of KPIs in Human Capital Management.

Answered: 1 week ago

Question

What are OLAP Cubes?

Answered: 1 week ago