Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This is about time complexity analysis of sorting problems. You have to find the

ID: 3633615 • Letter: T

Question

This is about time complexity analysis of sorting problems. You have to find the K=1000 most expensive products from one non-sorted list of values, of the products which contains N=10^7 different products.

-There are two suggested algorithms:

1st algorithm: Repeat sequential search 1000 times

2nd algorithm: Sort the list with the best algorithm for sorting, choosing at last the top 1000 products.

Which suggested algorithm will you prefer to use, knowing that the search of a product in a non-sorted list takes 0.1ms at the worst-case-scenario , and the sort of 100 products(with the best algorithm for sorting) takes 1msec.

You can say that the retreaval of product's prices is negligible quantity.

Explanation / Answer

1st Algorithm: I will prefer the first algorithm if the number of k is less, like k=1000, in comparison to total no of elements,10^7. 2nd Algorithm: I will prefer the second algorithm if the number of k is large or changing. I think that i will always take the second algorithm , because once the array is sorted i can find any number of k,after that. So please go with second algorithm.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote