NYU CSCI-UA 0002 - Introduction to Computers and Programming

Unformatted text preview:

Slide 1Slide 2Slide 3Slide 4Slide 5Slide 6Slide 7Slide 8Slide 9Slide 10Slide 11Slide 12Slide 13Slide 14Slide 15Slide 16Slide 17Slide 18Slide 19Slide 20Slide 21Slide 22Slide 23Introduction to: Intro to: Computers & Programming V22.0002Adam MeyersNew York University Introduction to:Introduction to: Computers & ProgrammingIntroduction to: Intro to: Computers & Programming V22.0002Outline•What is computer science?•What is a computer (hardware)?•What is a computer program (software)?•What is an algorithm?•What is a programming language, e.g., Python?•By 2020, why should all newly educated people know how to write computer programs?–Alternatively, do you believe that learning to program is unnecessary for the general population? I.e., should programming be left to specialists?Introduction to: Intro to: Computers & Programming V22.0002Some Quick Answers• A (modern) computer is: – A mechanical device that makes calculations and solves problems, consisting of physical components, aka hardware. Examples: main frame, work station, (cluster/farm), desktop, laptop, tablet computer, gps, cell phone, etc.•A computer program (software) is:–Sets of instructions which a computer can “interpret” to solve problems, make calculations, perform tasks, etc. • A programming language (like Python) is: – A formal “language” that humans use to write programs.• Computer Science is a field of study concerning:– The design of computer hardware and software– Modelling problems and using models to find solutionsIntroduction to: Intro to: Computers & Programming V22.0002History of the Modern Computer• 1837: Charles Babbage's analytical engine –The first programmable computer–Though he himself never completed a working model, working models have been built based on his plans.• Between 1842 and 1843: Ada Lovelace designed the first computer program (software) –Designed for Babbage's computer –She saw the non-number-crunching possibilities of Babbage's machine.Introduction to: Intro to: Computers & Programming V22.0002What is an Algorithm?• A precise “recipe” for solving a type of problem• A crude formalization of the PBJS Algorithm–Transfer slice of bread from loaf to plate–Repeat until enough peanut butter• Put knife into peanut butter jar and get peanut butter•Transfer peanut butter from knife to slice of bread–Transfer other slice of bread from loaf to plate–Repeat until enough jelly•Put knife into jelly jar and get jelly•Transfer jelly from knife to other slice of bread–Put slice of bread (pb side down) on other slice of breadIntroduction to: Intro to: Computers & Programming V22.0002Program = Implementation of Algorithm•The PBJS instructions in ACME sandwich maker 2000 implements the PBJS algorithm•The instructions refer to specific levers, switches and gears that are part of the ACME sandwich maker 2000•The instructions refer to specific types of knives, plates, breads, and jellies•Other PBJS instructions use different, but mathematically equivalent methods –The PJ-maker Deluxe squeezes peanut butter out of a squeezy bottle and does not use a knife, but otherwise follows the same algorithm.Introduction to: Intro to: Computers & Programming V22.0002Sandwich Making Algorithms Online•http://www.infopackets.com/news/technology/science/2002/20020919_algorithms_are_a_computer_programmers_best_friend.htm• http://scienceblogs.com/gregladen/2008/11/please_step_away_from_the_cold.php• http://library.thinkquest.org/06aug/02352/whataregeneticalgorithms.html•ETC•Most sandwich making algorithms online are the same–They involve getting ingredients and building a sandwich in essentially the same order–The McDonald's one is a little fancier (the 2nd one) because it deals with all different kinds of sandwiches– There are also some presentations of sandwich making algorithms designed to argue for the benefits of certain CS principles (object oriented, etc.)Introduction to: Intro to: Computers & Programming V22.0002Writing Algorithms•Design algorithms independently of programs–Focus on “best” way to solve a problem–Ignore punctuation, syntax, etc. of programming language• Use Pseudo Code (previous PBJ algorithm slide)•A Flow Chart (next slide)• One algorithm can be implemented as a computer program in many different computer languagesIntroduction to: Intro to: Computers & Programming V22.0002Flow Chart for PBJ algorithmIntroduction to: Intro to: Computers & Programming V22.0002Some Flowchart Conventions• Circles/Ovals are for Start and End•Rectangles represent steps in processing• Diamonds represent decision points–Yes or No–Multiple Choice–Etc.• Arrows show the sequence in which steps are applied.Introduction to: Intro to: Computers & Programming V22.0002Algorithms Predate Computer Science•The word algorithm:12th century based on 9th century Persian mathematician Muhammad ibn Mūsā al-Khwārizmī, founder of algebra• Formal processes in science/math have been described this way for centuries•Music algorithms: 10th Century to Present (Guido of Arezzo, Bach, Cage, Feldman, Brian Eno, Nine-Inch Nails)•Art algorithms: 8th century Islamic tile patterns, Escher, Sol Lewitt and modern computer artists• Algorithms implemented on computers are not subject to some human limitations (e.g., speed of computation, memory size, emotional bias), but are more limited in other ways (e.g., imagination, intuition, real world knowlege)Introduction to: Intro to: Computers & Programming V22.0002What is a Programming Language?•A formal language for encoding instructions that can be carried out by a computer–A formal language has a syntax, a strict set of rules for defining valid expressions in that language.–Syntax violations cause one of the main types of bugs (errors) in computer programs.• Computer languages: Python, JAVA, C, C++, Perl, Lisp, Prolog, Fortran, …• Some formal languages are not programming languages: propositional logic, arithmetic, HTML, XML, etc.Introduction to: Intro to: Computers & Programming V22.0002Low Level Programming Languages• Machine Language–Written in 0s and 1s–Different CPUs use different machine


View Full Document

NYU CSCI-UA 0002 - Introduction to Computers and Programming

Download Introduction to Computers and Programming
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Introduction to Computers and Programming and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Introduction to Computers and Programming 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?