If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

Main content

Measuring an algorithm's efficiency

Problem

An online store manages an inventory of millions of products. On their front page, they show customers products related to the ones they've recently bought.
This procedure comes up with a list of similar products for a given list of products:
PROCEDURE findSimilarProducts(products) {
   similarProducts ← [] 
   FOR EACH product IN products {
     similarProduct ← calcSimilar(product)
     APPEND(similarProducts, similarProduct)
   }
   RETURN similarProducts
}
The calcSimilar() procedure takes 2 minutes to return a result, as it needs to do a complicated series of database lookups and mathematic operations. The other operations, creating the empty list and appending items to the list, only take a few nanoseconds.
If the store calls the procedure on a list of 5 products, approximately how long will it take to complete?
Choose 1 answer:
🤔