A Computer Science Tapestry 1.1 A Computer Science Tapestry Exploring Programming and Computer Science with C++ Second Edition Owen Astrachan Duke University.

Slides:



Advertisements
Similar presentations
 Bheemarjuna Reddy Tamma IIT Hyderabad Lecture 1.
Advertisements

Counting the bits Analysis of Algorithms Will it run on a larger problem? When will it fail?
Chapter 1 An Overview of Computers and Programming Languages.
CSI 3125, Preliminaries, page 1 Programming languages and the process of programming –Programming means more than coding. –Why study programming languages?
Computability & Complexity. Scenario I can’t write this program because I’m too dumb.
CSC 2400 Computer Systems I Lecture 3 Big Ideas. 2 Big Idea: Universal Computing Device All computers, given enough time and memory, are capable of computing.
FLAC Lecture 19 Turing Machines and Real Life * Reductions Mihai Budiu March 3, 2000.
©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. COMPSCI 125 Introduction to Computer Science I.
The Theory of NP-Completeness
Introduction to Computers and Programming. Some definitions Algorithm: –A procedure for solving a problem –A sequence of discrete steps that defines such.
CS10 The Beauty and Joy of Computing Lecture #23 : Limits of Computing Thanks to the success of the Kinect, researchers all over the world believe.
CS 104 Introduction to Computer Science and Graphics Problems Software and Programming Language (2) Programming Languages 09/26/2008 Yang Song (Prepared.
Introduction to Computers and Programming. Some definitions Algorithm: Algorithm: A procedure for solving a problem A procedure for solving a problem.
Theory of Computation. Computation Computation is a general term for any type of information processing that can be represented as an algorithm precisely.
A Computer Science Tapestry 1.1 Wake up with CPS 006 Program Design and Methodology I Jeff Forbes
1 Programming Languages Examples: C, Java, HTML, Haskell, Prolog, SAS Also known as formal languages Completely described and rigidly governed by formal.
CPS Today’s topics l Computability ä Great Ideas Ch. 14 l Artificial Intelligence ä Great Ideas Ch. 15 l Reading up to this point ä Course Pack.
CPS Welcome! Principles of Computer Science CPS 1 LSRC B101 M, W, F 1:10-2:00 Professor Dietolf (Dee) Ramm
1 I.Introduction to Algorithm and Programming Algoritma dan Pemrograman – Teknik Informatika UK Petra 2009.
PROCESSING Designing and developing a program. Objectives Understand programming as the process of writing computer instructions that achieve a goal Understand.
Welcome Aboard – Chapter 1 COMP 2610 Dr. James Money COMP
THE PROCESS OF WRITING SOFTWARE Python: System Engineering 1.
CPS What is Computer Science? What is it that distinguishes it from the separate subjects with which it is related? What is the linking thread.
CompSci Welcome! Principles of Computer Science CompSci 1 LSRC B101 M, W, F 1:30-2:20 Professor Jeff Forbes.
© Janice Regan, CMPT 128, Jan CMPT 128 Introduction to Computing Science for Engineering Students Creating a program.
CS Introduction to Computing
High level & Low level language High level programming languages are more structured, are closer to spoken language and are more intuitive than low level.
Duke University Computer Science 1 Why Computer Science is Uglier and Prettier than Mathematics Owen Astrachan Duke University
1 TOPIC 1 INTRODUCTION TO COMPUTER SCIENCE AND PROGRAMMING Topic 1 Introduction to Computer Science and Programming Notes adapted from Introduction to.
Overview of Computing. Computer Science What is computer science? The systematic study of computing systems and computation. Contains theories for understanding.
Introduction CS 104: Applied C++ What is Programming? For some given problem: __________ a solution for it -- identify, organize & store the problem's.
Chapter 18 Limitations of Computing. Chapter Goals – THE BIG SLICES Limitations of Hardware Limitations of Software Limitations of Problems 2.
Algorithms and Programming
CS 102 Computers In Context (Multimedia)‏ 01 / 23 / 2009 Instructor: Michael Eckmann.
CompSci 1: Principles of Computer Science Lecture 1 Course Overview.
CompSci Welcome! Principles of Computer Science CompSci B101 LSRC M W F 1:30-2:20 Dietolf (Dee) Ramm
1 CPSC 185 Introduction to Computing The course home page
Gülşen Demiröz Fall 2011 CS 201 Introduction to Computing.
CSE 326: Data Structures NP Completeness Ben Lerner Summer 2007.
CS201 - Intro. to Sabancı University1 CS Introduction to Computing Albert Levi FENS 1091
Major objective of this course is: Design and analysis of modern algorithms Different variants Accuracy Efficiency Comparing efficiencies Motivation thinking.
Fundamental Programming: Fundamental Programming K.Chinnasarn, Ph.D.
Robert Crawford, MBA West Middle School.  Explain how the binary system is used by computers.  Describe how software is written and translated  Summarize.
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 1: An Overview of Computers and Programming Languages.
Genome Revolution: COMPSCI 006G 1.1 FOCUS COMPSCI 006G Genome Revolution Owen Astrachan
CompSci CompSci 6 Programming Design and Analysis I Dietolf (Dee) Ramm
Computer Science and Everything 1 Big Ideas in Computer Science l “Mathematics is the Queen of the Sciences” Carl Friedrich Gauss l What is Computer Science?
Compsci 100, Fall What is Computing? Informatics? l What is computer science, what is its potential?  What can we do with computers in our lives?
The Nature of Computing INEL 4206 – Microprocessors Lecture 2 Bienvenido Vélez Ph. D. School of Engineering University of Puerto Rico - Mayagüez.
Software Design 14.1 CPS 108 l Object oriented design and programming of medium-sized projects in groups using modern tools and practices in meaningful.
CS 127 Introduction to Computer Science. What is a computer?  “A machine that stores and manipulates information under the control of a changeable program”
Beauty and Joy of Computing Limits of Computing Ivona Bezáková CS10: UC Berkeley, April 14, 2014 (Slides inspired by Dan Garcia’s slides.)
Introduction 1 (Read Chap. 1) What is Programming? For some given problem: design a solution for it -- identify, organize & store the problem's data --
CPS What is Computer Science? What is it that distinguishes it from the separate subjects with which it is related? What is the linking thread.
CS10: The Beauty and Joy of Computing Lecture #22 Limits of Computing Warning sign posted at Stern Hall. Also, Apple releases new operating.
 Programming - the process of creating computer programs.
David Evans Class 16: NP-Completeness / The Story so Far CS150: Computer Science University of Virginia Computer Science.
Complexity & Computability. Limitations of computer science  Major reasons useful calculations cannot be done:  execution time of program is too long.
The Beauty and Joy of Computing Lecture #23 Limits of Computing Researchers at Facebook and the University of Milan found that the avg # of “friends” separating.
Computer and Programming. Computer Basics: Outline Hardware and Memory Programs Programming Languages and Compilers.
Chapter 1 An Overview of Computers and Programming Languages.
1 Computability Tractable, Intractable and Non-computable functions.
CS150: Computer Organization and Architecture Michael D. Wilder, Ph.D.
Lecture 1b- Introduction
CSCI-235 Micro-Computer Applications
CompSci 6 Introduction to Computer Science
Objective of This Course
CompSci 1: Principles of Computer Science Lecture 1 Course Overview
What is Computer Science at Duke?
Presentation transcript:

A Computer Science Tapestry 1.1 A Computer Science Tapestry Exploring Programming and Computer Science with C++ Second Edition Owen Astrachan Duke University McGraw-Hill

A Computer Science Tapestry 1.2 Computer Science and Programming l Computer Science is more than programming ä The discipline is called informatics in many countries ä Elements of both science and engineering Scientists build to learn, engineers learn to build –Fred Brooks ä Elements of mathematics, physics, cognitive science, music, art, and many other fields l Computer Science is a young discipline ä Fiftieth anniversary in 1997, but closer to forty years of research and development ä First graduate program at CMU (then Carnegie Tech) in 1965 l To some programming is an art, to others a science

A Computer Science Tapestry 1.3 What is Computer Science? What is it that distinguishes it from the separate subjects with which it is related? What is the linking thread which gathers these disparate branches into a single discipline? My answer to these questions is simple --- it is the art of programming a computer. It is the art of designing efficient and elegant methods of getting a computer to solve problems, theoretical or practical, small or large, simple or complex. C.A.R. (Tony)Hoare

A Computer Science Tapestry 1.4 Computer Science l Artificial Intelligencethinking machines l Scientific Computingweather, hearts l Theoretical CSanalyze algorithms, models l Computational Geometrytheory of animation, 3-D models l Architecturehardware-software interface l Software Engineeringpeopleware l Operating Systemsrun the machine l Graphicsfrom Windows to Hollywood l Many other subdisciplines

A Computer Science Tapestry 1.5 Algorithms as Cornerstone of CS l Step-by-step process that solves a problem ä more precise than a recipe ä eventually stops with an answer ä general process rather than specific to a computer or to a programming language l Searching: for phone number of G. Samsa, whose number is , or for the person whose number is l Sorting: zip codes, hand of cards, exams ä Why do we sort? What are good algorithms for sorting? It depends –Number of items sorted, kind of items, number of processors, ?? ä Do we need a detailed sorting algorithm to play cards?

A Computer Science Tapestry 1.6 Sorting Experiment l Groups of four people are given a bag containing strips of paper ä on each piece of paper is an 8-15 letter English word ä create a sorted list of all the words in the bag ä there are 100 words in a bag l What issues arise in developing an algorithm for this sort? ä l Can you write a description of an algorithm for others to follow? ä Do you need a support line for your algorithm? ä Are you confident your algorithm works?

A Computer Science Tapestry 1.7 Themes and Concepts of CS l Theory ä properties of algorithms, how fast, how much memory ä average case, worst case: sorting cards, words, exams ä provable properties, in a mathematical sense l Language ä programming languages: C++, Java, C, Perl, Fortran, Lisp, Scheme, Visual BASIC,... ä Assembly language, machine language, ä Natural language such as English l Architecture ä Main memory, cache memory, disk, USB, SCSI,... ä pipeline, multi-processor

A Computer Science Tapestry 1.8 Theory, Language, Architecture l We can prove that in the worst case quicksort is bad ä doesn’t matter what machine it’s executed on ä doesn’t matter what language it’s coded in ä unlikely in practice, but worst case always possible l Solutions? Develop an algorithm that works as fast as quicksort in the average case, but has good worst case performance ä quicksort invented in 1960 ä introsort (for introspective sort) invented in 1996 l Sometimes live with worst case being bad ä bad for sorting isn’t bad for other algorithms, needs to be quantified using notation studied as part of the theory of algorithms

A Computer Science Tapestry 1.9 Abstraction, Complexity, Models l What is an integer? ä In mathematics we can define integers easily, infinite set of numbers and operations on the numbers (e.g.,+, -, *, /) {…-3, -2, -1, 0, 1, 2, 3, …} ä In programming, finite memory of computer imposes a limit on the magnitude of integers. Possible to program with effectively infinite integers (as large as computation and memory permit) at the expense of efficiency At some point addition is implemented with hardware, but that’s not a concern to those writing software (or is it?) C++ doesn’t require specific size for integers, Java does l Floating-point numbers have an IEEE standard, required because it’s more expensive to do arithmetic with than with 2

A Computer Science Tapestry 1.10 Alan Turing ( ) l Instrumental in breaking codes during WW II l Developed mathematical model of a computer called a Turing Machine (before computers) ä solves same problems as a Pentium III (more slowly) l Church-Turing thesis ä All “computers” can solve the same problems l Showed there are problems that cannot be solved by a computer l Both a hero and a scientist/ mathematician, but lived in an era hard for gay people

A Computer Science Tapestry 1.11 Search, Efficiency, Complexity l Think of a number between 1 and 1,000 ä respond high, low, correct, how many guesses needed? l Look up a word in a dictionary ä Finding the page, the word, how many words do you look at? l Looking up a phone number in the Manhattan, NY directory ä How many names are examined? l How many times can 1,024 be cut in half? ä 2 10 = 1,024, 2 20 = 1,048,576

A Computer Science Tapestry 1.12 Complexity: Travelling Salesperson l Some problems are hard to solve, others seem hard to solve but we can’t prove that they’re hard (hard means computationally expensive) l Visit every city exactly once ä Minimize cost of travel or distance ä Is there a tour for under $2,000 ? less than 6,000 miles? l Must phrase question as yes/no, but we can minimize with binary search. l Is close good enough? Try all paths, from every starting point -- how long does this take? a, b, c, d, e, f, g b, a, c, d, e, f, g...

A Computer Science Tapestry 1.13 Complexity Classifications l Given a route and a claim: This route hits all cities for less than $2,000 ä verify properties of route efficiently. ä Hard to find optimal solution l Verification simple, finding optimal solution is hard l Other problems are similar Pack trucks with barrels, use minimal # trucks Ideas? Problems are the “same hardness”: solve one efficiently, solve them all

A Computer Science Tapestry 1.14 Are hard problems easy? l P = easy problems, NP = “hard” problems ä P stands for polynomial, like x 2 or x 3 ä NP stands for non-deterministic, polynomial guess a good solution l Question: P = NP ? ä if yes, a whole suite of difficult problems can be solved efficiently ä if no, none of the hard problems can be solved efficiently l Problem posed in 1971, central to the field Most computer scientists believe P  NP, this is arguably the most important unsolved problem in computer science

A Computer Science Tapestry 1.15 C.A.R. (Tony) Hoare (b. 1934) l Won Turing award in 1980 l Invented quicksort, but didn’t see how simple it was to program recursively l Developed mechanism and theory for concurrent processing l In Turing Award speech used “Emporer’s New Clothes” as metaphor for current fads in programming “ Beginning students don’t know how to do top-down design because they don’t know which end is up ”

A Computer Science Tapestry 1.16 Creating a Program l Specify the problem ä remove ambiguities ä identify constraints l Develop algorithms, design classes, design software architecture l Implement program ä revisit design ä test, code, debug ä revisit design l Documentation, testing, maintenance of program l From ideas to electrons

A Computer Science Tapestry 1.17 From High- to Low-level languages l C++ is a multi-purpose language, we’ll use it largely as an object-oriented language, but not exclusively ä Contrast, for example, with Java in which everything is a class ä Contrast with Fortran in which nothing is a class l Compilers translate C++ to a machine-specific executable program ä The compiler is a program, input is C++, output is an executable ä What language is the compiler written in? ä In theory C++ source code works on any machine given a compiler for the machine l C++ and other programming language are more syntactically rigid than English and other natural languages

A Computer Science Tapestry 1.18 Levels of Programming Language l Machine specific assembly language, Sparc on left, Pentium on right, both generated from the same C++ main: save %sp,-128,%sp pushl %ebp mov 7,%o0 movl %esp,%ebp st %o0,[%fp-20] subl $12,%esp mov 12,%o0 movl $7,-4(%ebp) st %o0,[%fp-24] movl $12,-8(%ebp) ld [%fp-20],%o0 movl -4(%ebp),%eax ld [%fp-24],%o1 imull -8(%ebp),%eax call.umul,0 movl %eax,-12(%ebp) nop xorl %eax,%eax st %o0,[%fp-28] jmp.L1 mov 0,%i0.align 4 b.LL1 xorl %eax,%eax nop jmp.L1

A Computer Science Tapestry 1.19 Alternatives to compilation l Some languages are interpreted, Scheme and Java are examples ä like simultaneous translation instead of translation of written document. The same word may be translated many times ä The interpreter is a program that translates one part of a source code at a time The interpreter is machine specific, written in some programming language l JVM, the Java Virtual Machine ä Like a PC or Mac but machine is virtual, written in software ä Executes Java byte codes which are created from Java source Like assembly language: between source code and executable ä JVM must be written for each architecture, e.g., Linux, Windows, Mac, BeOS,...

A Computer Science Tapestry 1.20 What is a computer? l Turing machine: invented by Alan Turing in 1936 as a theoretical model infinite tape, moving tape-reader 0 1 Mainframe, PC,laptop, supercomputer A computer is a computer, is a computer, Church-Turing Thesis, all have same “power”

A Computer Science Tapestry 1.21 Chips, Central Processing Unit (CPU) l CPU chips ä Pentium (top) ä G3 (bottom) ä Sound, video, … l Moore’s Law ä chip “size” (# transistors) doubles every months (formulated in 1965) ä 2,300 transistors Intel 4004, 7.5 million Intel Pentium II

A Computer Science Tapestry 1.22 Why is programming fun? What delights may its practitioner expect as a reward? First is the sheer joy of making things Second is the pleasure of making things that are useful Third is the fascination of fashioning complex puzzle-like objects of interlocking moving parts Fourth is the joy of always learning Finally, there is the delight of working in such a tractable medium. The programmer, like the poet, works only slightly removed from pure thought- stuff. Fred Brooks