Question

1. For each of the following tasks find the complexity of the algorithm using big O...

1. For each of the following tasks find the complexity of the algorithm using big O notation. You must justify your answer with 1-2 lines of explanation.

a) Insert a new element into an unsorted linked list

b) Insert a new element into a sorted linked list

c) Remove the minimum element in an unsorted linked list

d) Remove the minimum element in a sorted linked list

0 0
Add a comment Improve this question Transcribed image text
Answer #1

`Hey,

Note: Brother if you have any queries related the answer please do comment. I would be very happy to resolve all your queries.

a)

Since it is unsorted linkedlist. So, it will be O(1) since we can connect directly to tail

b)

Since it is sorted so it will be O(n) since we have to find the position.

c)

Removing minimum is O(n) in unsorted since we have to find in O(n)

d)

Removing minimum will be O(1) in sorted by head=head->next

Kindly revert for any queries

Thanks.

Add a comment
Know the answer?
Add Answer to:
1. For each of the following tasks find the complexity of the algorithm using big O...
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