Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Follow the loop - based algorithm time complexity analysis guideline and discuss with your team members about time complexity for the following pseudocodes. Note that

Follow the loop-based algorithm time complexity analysis guideline and discuss with your team members about time complexity for the following pseudocodes. Note that in pseudocode, we ignore the data type declaration.
Find the matching runtime complexity for each psedudocode:
A)
findMin(x, y){
if (x < y)
return x
else
return y
}
B)
LinearSearch(numbers, N, key){
for (i =0; i < N; ++i)
if (numbers[i]== key)
return i
return -1// not found
}
C)
SelectionSort(number, N){
for (i =0; i < N; ++i){
indexSmallest = i
for (j = i +1; j < N; ++j)
if (numbers[j]< numbers[indexSmallest])
indexSmallest = j
temp = numbers[i]
numbers[i]= numbers[indexSmallest]
numbers[indexSmallest]= temp
}
}
D)
BinarySearch(sortedNumbers, N, key){
mid =0
low =0
high =0
high = N -1
while (high >= low){
mid =(high + low)/2
if (sortedNumbers [mid]< key)
low = mid +1
else if (sortedNumbers [mid]> key)
high = mid -1
else
return mid
}
return -1// not found
}
E)
for (int i =0; i < n; i++)
for (int j =1; j < n; j = j *2)
System.out.println("hello");
F)
for (int i =0; i < n; i = i +2)
for (int j =1; j < n; j = j *3)
System.out.println("hello");
G)
for (int i =1; i < n; i = i *2)
for (int j =1; j < n; j = j *3)
System.out.println("hello");
Group of answer choices
A
O(1)
B
O(N)
C
O(N * N)
D
O( N * log N)
E
O( log N)
F
O(N)
G
O(N)

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_2

Step: 3

blur-text-image_3

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2010 Barcelona Spain September 2010 Proceedings Part 1 Lnai 6321

Authors: Jose L. Balcazar ,Francesco Bonchi ,Aristides Gionis ,Michele Sebag

2010th Edition

364215879X, 978-3642158797

More Books

Students also viewed these Databases questions

Question

What magazine and ads did you choose to examine?

Answered: 1 week ago