Compsci 06/101, Fall 2010 16.1 What is Computing? Informatics? l What is computer science, what is its potential?  What can we do with computers in our.

Slides:



Advertisements
Similar presentations
Computability & Complexity. Scenario I can’t write this program because I’m too dumb.
Advertisements

Introductory Lecture. What is Discrete Mathematics? Discrete mathematics is the part of mathematics devoted to the study of discrete (as opposed to continuous)
Department of Mathematics and Computer Science
Java.  Java is an object-oriented programming language.  Java is important to us because Android programming uses Java.  However, Java is much more.
CSE332: Data Abstractions Lecture 27: A Few Words on NP Dan Grossman Spring 2010.
CMPT 120 Introduction to Computer Science and Programming I Chris Schmidt.
Analysis of Algorithms CS 477/677
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.
Computer Science - I Course Introduction Computer Science Department Boston College Hao Jiang.
CSE 131 Computer Science 1 Module 1: (basics of Java)
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.
Week 4-5 Java Programming. Loops What is a loop? Loop is code that repeats itself a certain number of times There are two types of loops: For loop Used.
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.
Duke University Computer Science 1 Why Computer Science is Uglier and Prettier than Mathematics Owen Astrachan Duke University
Peter Andreae Computer Science Victoria University of Wellington Copyright: Peter Andreae, Victoria University of Wellington Summary and Exam COMP 102.
Cs3102: Theory of Computation Class 18: Proving Undecidability Spring 2010 University of Virginia David Evans.
Compsci 100, Fall ’.1 Views of programming l Writing code from the method/function view is pretty similar across languages  Organizing methods.
ICAPRG301A Week 4Buggy Programming ICAPRG301A Apply introductory programming techniques Program Bugs US Navy Admiral Grace Hopper is often credited with.
Instructor: Tina Tian. About me Office: RLC 203A Office Hours: Wednesday 1:30 - 4:30 PM or .
Media Computing Instructor Byung Kim Olsen 231 Office hours – MWF 9:00-10:00 AM or by appointment.
Class 37: Computability in Theory and Practice cs1120 Fall 2011 David Evans 21 November 2011 cs1120 Fall 2011 David Evans 21 November 2011.
Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 13: An Introduction to C++
Tonga Institute of Higher Education Design and Analysis of Algorithms IT 254 Lecture 8: Complexity Theory.
CS 11 java track: lecture 1 Administrivia need a CS cluster account cgi-bin/sysadmin/account_request.cgi need to know UNIX
MIT and James Orlin1 NP-completeness in 2005.
Compsci 06/101, Spring What is Computing? Informatics? l What is computer science, what is its potential?  What can we do with computers in.
CSE 131 Computer Science 1 Module 1: (basics of Java)
CSCI 51 Introduction to Computer Science Dr. Joshua Stough January 20, 2009.
Netprog: Java Intro1 Crash Course in Java. Netprog: Java Intro2 Why Java? Network Programming in Java is very different than in C/C++ –much more language.
Discrete Structures for Computing
Software Design 8.1 A Rose by any other name…C or Java? l Why do we use Java in our courses (royal we?)  Object oriented  Large collection of libraries.
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?
Halting Problem Introduction to Computing Science and Programming I.
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?
We will talking about story of JAVA language. By Kristsada Songpartom.
CompSci What can be computed l What class of problems can be solved? ä Google Datacenter, Desktop computer, Cell phone, pencil? ä Alan Turing proved.
Compsci 06/101, Spring What is Computing? Informatics? l What is computer science, what is its potential?  What can we do with computers in.
Compsci 100, Spring What’s left to talk about? l Transforms  Making Huffman compress more  Understanding what transforms do Conceptual understanding,
Beauty and Joy of Computing Limits of Computing Ivona Bezáková CS10: UC Berkeley, April 14, 2014 (Slides inspired by Dan Garcia’s slides.)
Fall 2002CS 150: Intro. to Computing1 Streams and File I/O (That is, Input/Output) OR How you read data from files and write data to files.
CPS 100, Fall What is Computing? Informatics? l What is computer science, what is its potential?  What can we do with computers in our lives?
CompSci Problem: finding subsets l See CodeBloat APT, requires finding sums of all subsets  Given {72, 33, 41, 57, 25} what is sum closest (not.
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.
SNU OOPSLA Lab. 1 Great Ideas of CS with Java Part 1 WWW & Computer programming in the language Java Ch 1: The World Wide Web Ch 2: Watch out: Here comes.
CS10: The Beauty and Joy of Computing Lecture #22 Limits of Computing Warning sign posted at Stern Hall. Also, Apple releases new operating.
Complexity & Computability. Limitations of computer science  Major reasons useful calculations cannot be done:  execution time of program is too long.
2101INT – Principles of Intelligence Systems Lecture 3.
ICS3U_FileIO.ppt File Input/Output (I/O)‏ ICS3U_FileIO.ppt File I/O Declare a file object File myFile = new File("billy.txt"); a file object whose name.
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.
CSE 311 Foundations of Computing I Lecture 28 Computability: Other Undecidable Problems Autumn 2011 CSE 3111.
Compsci 101, Fall LWoC l Review Recommender, dictionaries, files  How to create recommendations in order? food.txt  Toward a Duke eatery-recommender.
CS216: Program and Data Representation University of Virginia Computer Science Spring 2006 David Evans Lecture 8: Crash Course in Computational Complexity.
CompSci 100e 12.1 Sorting: In 2 Slides l Why do people study sorting?  Because we have to  Because sorting is beautiful  Example of algorithm analysis.
Computer Science A 1. Course plan Introduction to programming Basic concepts of typical programming languages. Tools: compiler, editor, integrated editor,
1 1. Which of these sequences correspond to Hamilton cycles in the graph? (a) (b) (c) (d) (e)
Compsci 101.2, Fall Plan for LDO101 l Ethical webpage scraping  Illustrate power of regular expressions  Python makes trying things relatively.
Introductory Lecture. What is Discrete Mathematics? Discrete mathematics is the part of mathematics devoted to the study of discrete (as opposed to continuous)
CS10: The Beauty and Joy of Computing Lecture #21 Limits of Computing Instructor: Sean Morris UCB announces The Turing Test Tournament.
CSC 222: Object-Oriented Programming
Introduction to Computing Science and Programming I
Bottom up meets Top down
Compsci 6/101: I Python Techniques for looping
Chapter No. : 1 Introduction to Java.
What is Computing? Informatics?
Views of programming Writing code from the method/function view is pretty similar across languages Organizing methods is different, organizing code is.
Discrete Mathematics and Its Applications
CompSci 1: Principles of Computer Science Lecture 1 Course Overview
Discrete Mathematics in the Real World
What is Computer Science at Duke?
From bit to byte to char to int to long
Presentation transcript:

Compsci 06/101, Fall What is Computing? Informatics? l What is computer science, what is its potential?  What can we do with computers in our lives?  What can we do with computing for society?  Will networks transform thinking/knowing/doing?  Society affecting and affected by computing?  Changes in science: biology, physics, chemistry, … l Privileges and opportunities available if you know code  Writing and reading code, understanding algorithms  Majestic, magical, mathematical, mysterious, …

Compsci 06/101, Fall Computer Science: Duke Connection l What we tell you it is  A bunch of courses useful in some majors l What you want it to be or imagine it to be  Independent study, new courses, interdepartmental major l What will it be in one year or two?  New courses, new professors, new majors, … l What is it outside of Duke?  Similar but different!

Compsci 06/101, Fall Computer Science: Duke Connection l Algorithms, Distributed Systems, Networks, Bioinformatics, Graphics, Software Design, Probability, Modeling, Artificial Intelligence, Architecture, Programming, Statistics, Databases, Linear Algebra, Scientific Computing

Compsci 06/101, Fall Fundamental Compsci Concepts l “Mathematics is the Queen of the Sciences” Carl Friedrich Gauss l What is Computer Science?  Why study it, what is it, why is it interesting (or not)? l Historically  What can we program: at all, efficiently, optimally l Present  Lots of data, lots of connectivity, lots of inferences l Future  Where do we go from here?

Compsci 06/101, Fall What can be programmed? l What class of problems can be solved ?  Hadoop, Intel i7, Mac, Windows7, Android,…  Alan Turing contributions Halting problem, Church-Turing thesis l What class of problems can be solved efficiently ?  Problems with no practical solution What does practical mean?  We can’t find a practical solution Solving one solves them all Would you rather be rich or famous?

Compsci 06/101, Fall Schedule students, minimize conflicts l Given student requests, available teachers  write a program that schedules classes  Minimize conflicts l Add a GUI too  Web interface  … I can’t write this program because I’m too dumb

Compsci 06/101, Fall One better scenario I can’t write this program because it’s provably impossible I can’t write this program but neither can all these famous people Still another scenario, is this better?

Compsci 06/101, Fall Entscheidungsproblem l What can we program?  What kind of computer? l What can't we program?  Can’t we try harder? l Can we write a program that will determine if any program P will halt when run on input S ?  Input to halt: P and S  Output: yes/no halts

Compsci 06/101, Fall Good sites: l What is social bookmarking?  Why is del.icio.us interesting?  Who posts, who visits? l What about a website of interesting websites?  What would you expect to find there?  Would the site list itself? l What about sites that list/link to themselves?  What about a site with all sites that list themselves?

Compsci 06/101, Fall Bad sites: l Sites listing bad sites (don’t visit them?)  Where would this be useful?  What about censorship (internationally?)  Is this a good site or a bad site? l What about sites that list/link themselves?  Is haz.ardo.us there? l Website of all the sites that don’t list themselves?  Is notlisted.com listed on notlisted.com ?

Compsci 06/101, Fall halting module/problem: writing doesHalt """ function doesHalt returns True if progname halts when run on input, and False if progname doesn't halt (infinite loop) """ def doesHalt(progname,input): #code here name = "ActivateGame.py" data = "input.txt" if doesHalt(name,data): print "program ended!" l A Python intepreter reads other programs as input  Can a word counting program count its own words? The doesHalt method might simulate, analyze, …  One program/function that works for any program/input

Compsci 06/101, Fall How to tell if X stops/halts on Y import halting def runHalt(): prog = "ActivateGame.py"; input = "["abc", "def", "hij"]" if halting.doesHalt(prog,input): print prog,"stops" else: print prog,"loops 4ever" l Can user enter name of program, X? Input, Y?  What's the problem with this program?

Compsci 06/101, Fall Consider this module Confuse.py import halting print "enter name of program", prog = raw_input() if halting.doesHalt(prog,prog): while True: pass print "finished" We want to show writing doesHalt is impossible  Proof by contradiction:  Assume possible, show impossible situation results l Can a program read a program? Itself?

Compsci 06/101, Fall Travelling Salesperson l Visit every city exactly once l Minimize cost of travel or distance l Is there a tour for under $2,000 ? less than 6,000 miles? l Is close good enough?  Within 10% of optimal  Within 50% of optimal  … 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...

Compsci 06/101, Fall Theory and Practice l l l l How do we create an Ajax-based solution to the data-based back website we're building to do online course evaluations?

Compsci 06/101, Fall Are hard problems easy? Clay PrizeClay Prize l P = easy problems, NP = “hard” problems  P means solvable in polynomial time Difference between N, N 2, N 10 ?  NP means non-deterministic, polynomial time guess a solution and verify it efficiently l Question: P = NP ?  if yes, a whole class of difficult problems, the NP-complete problems, can be solved efficiently  if no, no hard problems can be solved efficiently  showing the first problem was NP complete was an exercise in intellectual bootstrapping, satisfiability/Cook/(1971)

Compsci 06/101, Fall Theory and Practice l Number theory: pure mathematics  How many prime numbers are there?  How do we factor?  How do we determine primeness? l Computer Science  Primality is “easy”  Factoring is “hard”  Encryption is possible top secret public-key cryptography randomized primality testing

Compsci 06/101, Fall Wikileaks, PGP, PKI, verification l l Where are wikileaks servers and how to find them?  What if they’re taken down  Where is information  What about imposters or verification? l File x distributed  Download  Verify integrity and source!

Compsci 06/101, Fall A Rose by any other name…C or Java? l Why do we use [Python|Java] in courses ?  [is|is not] Object oriented  Large collection of libraries  Safe for advanced programming and beginners  Harder to shoot ourselves in the foot l Why don't we use C++ (or C)?  Standard libraries weak or non-existant (comparatively)  Easy to make mistakes when beginning  No GUIs, complicated compilation model  What about other languages?

Compsci 06/101, Fall Why do we learn other languages? l Perl, Python, PHP, Ruby, C, C++, Java, Scheme, ML,  Can we do something different in one language? Depends on what different means. In theory: no; in practice: yes  What languages do you know? All of them.  In what languages are you fluent? None of them l In later courses why do we use C or C++?  Closer to the machine, understand abstractions at many levels  Some problems are better suited to one language Writing an operating system? Linux?

Compsci 06/101, Fall Unique words in Java import java.util.*; import java.io.*; public class Unique { public static void main(String[] args) throws IOException{ Scanner scan = new Scanner(new File("/data/melville.txt")); TreeSet set = new TreeSet (); while (scan.hasNext()){ String str = scan.next(); set.add(str); } for(String s : set){ System.out.println(s); }

Compsci 06/101, Fall Bjarne Stroustrup, Designer of C++ l Numerous awards, engineering and science  ACM Grace Hopper l Formerly at Bell Labs  Now Texas A&M l “There's an old story about the person who wished his computer was as easy to use as his telephone. That wish has come true, since I no longer know how to use my telephone.” Bjarne Stroustrup

Compsci 06/101, Fall Unique words in C++ #include using namespace std; int main(){ ifstream input("/data/melville.txt"); set unique; string word; while (input >> word){ unique.insert(word); } set ::iterator it = unique.begin(); for(; it != unique.end(); it++){ cout << *it << endl; } return 0; }

Compsci 06/101, Fall PHP, Rasmus Lerdorf and Others l Rasmus Lerdorf  Qeqertarsuaq, Greenland  1995 started PHP, now part of it  l Personal Home Page  No longer an acronym l “When the world becomes standard, I will start caring about standards.” Rasmus Lerdorf

Compsci 06/101, Fall Unique words in PHP <?php $wholething = file_get_contents("file:///data/melville.txt"); $wholething = trim($wholething); $array = preg_split("/\s+/",$wholething); $uni = array_unique($array); sort($uni); foreach ($uni as $word){ echo $word." "; } ?>

Compsci 06/101, Fall Guido van Rossum l BDFL for Python development  Benevolent Dictator For Life  Late 80’s began development l Python is multi-paradigm  OO, Functional, Structured, … l We're looking forward to a future where every computer user will be able to "open the hood" of their computer and make improvements to the applications inside. We believe that this will eventually change the nature of software and software development tools fundamentally. Guido van Rossum, 1999!

Compsci 06/101, Fall Unique Words in Python #! /usr/bin/env python def main(): f = open('/data/melville.txt', 'r') words = f.read().strip().split() allWords = set() for w in words: allWords.add(w) for word in sorted(allWords): print word if __name__ == "__main__": main()

Compsci 06/101, Fall Kernighan and Ritchie l First C book, 1978 l First ‘hello world’ l Ritchie: Unix too!  Turing award 1983 l Kernighan: tools  Strunk and White l Everyone knows that debugging is twice as hard as writing a program in the first place. So if you are as clever as you can be when you write it, how will you ever debug it? Brian Kernighan

Compsci 06/101, Fall How do we read a file in C? #include int strcompare(const void * a, const void * b){ char ** stra = (char **) a; char ** strb = (char **) b; return strcmp(*stra, *strb); } int main(){ FILE * file = fopen("/data/melville.txt","r"); char buf[1024]; char ** words = (char **) malloc(5000*sizeof(char **)); int count = 0; int k;

Compsci 06/101, Fall Storing words read when reading in C while (fscanf(file,"%s",buf) != EOF){ int found = 0; // look for word just read for(k=0; k < count; k++){ if (strcmp(buf,words[k]) == 0){ found = 1; break; } if (!found){ // not found, add to list words[count] = (char *) malloc(strlen(buf)+1); strcpy(words[count],buf); count++; } l Complexity of reading/storing? Allocation of memory ?

Compsci 06/101, Fall Sorting, Printing, Freeing in C qsort(words,count,sizeof(char *), strcompare); for(k=0; k < count; k++) { printf("%s\n",words[k]); } for(k=0; k < count; k++){ free(words[k]); } free(words); } l Sorting, printing, and freeing  How to sort? Changing sorting mechanism?  Why do we call free? Where required?

Compsci 06/101, Fall Courses of Study l What do you take first? l What’s next? l In between? l Who teaches what?