Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!