



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
During the course work of Thinking Like Computers, we study the key concept of artificial intelligence. The main points in these lecture slides are:Local Versus Global Variables, Errors to Avoid, Javascript Functions, Designing
Typology: Slides
1 / 5
This page cannot be seen from the preview
Don't miss anything!
if the SCRIPT tags are malformed or the name/address of the library is incorrect, the library will fail to load this will not cause an error in itself, but any subsequent attempt to call a function from the library will produce “Error: Object Expected” (using Internet Explorer) or “Error: XXX is not a function” (using Navigator), where XXX represents the typed function name
when you use the SRC attribute in a pair of SCRIPT tags to load a code library, you cannot place additional JavaScript code between the tags think of the SRC attribute as causing the contents of the library to be inserted between the tags, overwriting any other code that was erroneously placed there
if you want additional JavaScript code or another library, you must use another pair of SCRIPT tags
create an algorithm for accomplishing a given objective, then translate the individual steps of the algorithm into a programming language that the computer can understand
e.g., recipes for baking cookies e.g., directions to your house
in order for an algorithm to be effective, it must be stated in a manner that its intended executor can understand a recipe written for a master chef will look different than a recipe written for a college student as you have already experienced, computers are more demanding with regard to algorithm specifics than any human could be
initial condition – room full of people goal – identify the oldest person assumptions 9 a person will give their real birthday 9 if two people are born on the same day, they are the same age 9 if there is more than one oldest person, finding any one of them is okay
when there is only one person left in line, that person is the oldest
it depends upon what features are most important to you if you want to be sure it works, choose the clearer algorithm if you care about the time or effort required, need to analyze performance
the amount of time to find the oldest person is proportional to the number of people if you double the amount of people, the time needed to find the oldest person will also double
suppose you have a sorted list of state names, and want to find Illinois
as a result, you will have to inspect and compare every entry in the list
Æ sequential search is an O(N) algorithm
each time you inspect/compare an entry, you rule out roughly half the remaining entries
Æ binary search is an O(log N) algorithm
i. refine the approximation using the formula: newApproximation = (oldApproximation + N/oldApproximation)/
however, since the square root might be a non-terminating fraction it is difficult to define the exact number of steps for convergence
Æ demonstrates O(log N) behavior
a machine language consists of instructions that correspond directly to the hardware operations of a particular machine i.e., instructions deal directly with the computer’s physical components including main memory, registers, memory cells in CPU very low level of abstraction machine language instructions are written in binary programming in machine language is tedious and error prone code is nearly impossible to understand and debug