



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




example: programming in JavaScript
a recipe written for a master chef will look different than a recipe written for a 12 year old
i. ask the person for his or her name and birthday ii. if the stated birthday is earlier than the birthday on the paper, cross out old information and write down the name and birthday of this person
1,000,000 people 5*1,000,000 = 5,000,000 seconds or 57 days
1,000,000 people 5* log 2 1,000,000 = 100 seconds or 1.6 minutes
if the computer selected entries at random, there is no assurance that the particular record will be found even if the record is found, it is likely to take a large amount of time a systematic approach assures that a given record will be found, and that it will be found more efficiently
sequential search is an algorithm that involves examining each
sequential search for finding an item in a list
but it is not very practical for very large databases worst case: you may have to look at every entry in the list
binary search involves continually cutting the desired search
e.g., a list of numbers in increasing order e.g., a list of words in alphabetical order
by repeatedly cutting the potential range in half, binary search can hone in on the value very quickly
suppose you have a sorted list of state names, and want to find Illinois
in the worst case, the item you are looking for is in the last spot in the list (or not in the list at all) as a result, you will have to inspect and compare every entry in the list the amount of work required is proportional to the list size sequential search is an O(N) algorithm
in the worst case, you will have to keep halving the list until it gets down to a single entry each time you inspect/compare an entry, you rule out roughly half the remaining entries the amount of work required is proportional to the logarithm of the list size binary search is an O(log N) algorithm