Question

QUESTION 5

  1. What is the worst-case complexity of line 10 of function bar?

1 2 int bar (int* A, int* B, int N) P { int count = 0; for (int i = 0; i < N; ++i) 00 voow int x = A[i]; int pos = sequential

A.

O(1)

B.

O(N)

C.

O(i)

D.

O(log N)

E.

O(sqrt N)

F.

O(A[i])

G.

O(N sqrt N)

H.

O(N log N)

I.

O(N^2)

J.

O(i^2)

K.

None of the above

QUESTION 6

  1. What is the worst-case complexity of lines 8-11 of function bar?

1 2 int bar (int* A, int* B, int N) { int count = 0; for (int i = 0; i < N; ++i) O vouw int x = A[i]; int pos = binarySearch

A.

O(1)

B.

O(N)

C.

O(i)

D.

O(log N)

E.

O(sqrt N)

F.

O(A[i])

G.

O(N sqrt N)

H.

O(N log N)

I.

O(N^2)

J.

O(i^2)

K.

None of the above

QUESTION 7

  1. What is the worst-case complexity of line 6 of function bar?

1 2 int bar (int* A, int* B, int N) { int count = 0; for (int i = 0; i < N; ++i) O vouw int x = A[i]; int pos = binarySearch

A.

O(1)

B.

O(N)

C.

O(i)

D.

O(log N)

E.

O(sqrt N)

F.

O(A[i])

G.

O(N sqrt N)

H.

O(N log N)

I.

O(N^2)

J.

O(i^2)

K.

None of the above

0 0
Add a comment Improve this question Transcribed image text
Answer #1
QUESTION 5
worst-case complexity of line 10 of function bar is O(1)
Answer:
O(1)

QUESTION 6
worst-case complexity of lines 8-11 of function bar is O(1)
Answer:
O(1)

QUESTION 7
worst-case complexity of line 6 of function bar is O(1)
Answer:
O(1)
Add a comment
Know the answer?
Add Answer to:
QUESTION 5 What is the worst-case complexity of line 10 of function bar? A. O(1) B....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT