CompSci 100e1.1 Welcome! Program Design and Analysis II for Engineers CompSci 100E Soc Psy 126 W, F 2:50-4:05 Professor Jeff Forbes

Slides:



Advertisements
Similar presentations
Designing a Program & the Java Programming Language
Advertisements

Lecture 0 CSIS10A Overview. Welcome to CSIS10A (5 mins) – Typical format for class meetings New material first (monitors off, notebooks out) Practice.
1 Java Basics. 2 Compiling A “compiler” is a program that translates from one language to another Typically from easy-to-read to fast-to-run e.g. from.
June 13, Introduction to CS II Data Structures Hongwei Xi Comp. Sci. Dept. Boston University.
01 Introduction1June Introduction CE : Fundamental Programming Techniques.
Slide 1 of 40. Lecture A The Java Programming Language Invented 1995 by James Gosling at Sun Microsystems. Based on previous languages: C, C++, Objective-C,
July 16, Introduction to CS II Data Structures Hongwei Xi Comp. Sci. Dept. Boston University.
1 An Extremely Short Introduction to Computer Programming Mike Scott.
Lecture 1: Overview of Java. What is java? Developed by Sun Microsystems (James Gosling) A general-purpose object-oriented language Based on C/C++ Designed.
CSE 131 Computer Science 1 Module 1: (basics of Java)
BASIC JAVA PROGRAMMING TUTORIAL. History  James Gosling and Sun Microsystems  Oak  Java, May 20, 1995, Sun World  Hot Java –The first Java-enabled.
Computer Programming My Home Page My Paper Job Description Computer programmers write, test, and maintain the detailed instructions, called programs,
Compsci 101, Spring COMPSCI 101, Spring 2012 Introduction to Computer Science Owen Astrachan
CSC 142 A 1 CSC 142 Introduction to Java [Reading: chapter 0]
CPS 100, Fall COMPSCI 100, Fall 2011 Owen Astrachan w/ Michael Hewner
CompSci 100E Gambler's Ruin  One approach. Monte Carlo simulation.  Flip digital coins and see what happens. o Pseudorandom number generation ojava.util.Random.
CS101: Introduction to Computer Science Slides adapted from Sedgewick and Wayne Copyright © Your First Program.
Java Workshop for Teachers May 6, 2005 A Brief Look at the Java Programming Language.
1 Introduction to Computer Science Spring 2009 Sudhanva Gurumurthi CS 101E.
1 TOPIC 1 INTRODUCTION TO COMPUTER SCIENCE AND PROGRAMMING Topic 1 Introduction to Computer Science and Programming Notes adapted from Introduction to.
CompSci 100e Program Design and Analysis II January 18, 2011 Prof. Rodger CompSci 100e, Spring20111.
Java: Chapter 1 Computer Systems Computer Programming II.
CompSci 100e1.1 Welcome! Program Design and Analysis II for Engineers CompSci 100E French 2231 M, W 2:50-4:05 Professor Jeff Forbes
CS 106 Introduction to Computer Science I 01 / 25 / 2010 Instructor: Michael Eckmann.
CPS 100, Spring COMPSCI 100, Spring 2010 Owen Astrachan
Compsci 06/101, Fall COMPSCI 06/101, Fall 2010 Owen Astrachan Robert Duvall
Media Computing Instructor Byung Kim Olsen 231 Office hours – MWF 9:00-10:00 AM or by appointment.
Sadegh Aliakbary Sharif University of Technology Fall 2012.
Chapter 1 CSIS-120: Java Intro. What is Programming?  A: It is what makes computer so useful.  The flexibility of a computer is amazing  Write a term.
1.1 Your First Program Introduction to Programming in Java: An Interdisciplinary Approach · Robert Sedgewick and Kevin Wayne · Copyright © 2008 · October.
1.8History of Java Java –Based on C and C++ –Originally developed in early 1991 for intelligent consumer electronic devices Market did not develop, project.
CS 11 java track: lecture 1 Administrivia need a CS cluster account cgi-bin/sysadmin/account_request.cgi need to know UNIX
May 9, 2002Serguei A. Mokhov, 1 Kickstart Intro to Java Part I COMP346/ Operating Systems Revision 1.6 February 9, 2004.
Compiling and the Java Virtual Machine (JVM). The syntax of Pseudocode is pretty loose –visual validation encourages a permissive approach –emphasized.
CPS 100, Fall COMPSCI 100, Fall 2009 Owen Astrachan
Working with arrays (we will use an array of double as example)
Introduction to programming in the Java programming language.
What Is Java? According to Sun in a white paper: Java: A simple, object-oriented, network-savvy, interpreted, robust, secure, architecture-neutral, portable,
CompSci CompSci 6 Programming Design and Analysis I Dietolf (Dee) Ramm
National Taiwan University Department of Computer Science and Information Engineering National Taiwan University Department of Computer Science and Information.
Lecture.1: Getting Started With Java Jiang (Jen) ZHENG May 9 th, 2005.
CompSci 100E 1.1 CompSci 100E Dietolf (Dee) Ramm Robert A. Wagner
Pre-Sessional Java Programming Lecture 1a Reyer Zwiggelaar
CompSci 100E Functions (Static Methods)  Java function.  Takes zero or more input arguments.  Returns one output value.  Applications.  Scientists.
Introduction to Python Lesson 1 First Program. Learning Outcomes In this lesson the student will: 1.Learn some important facts about PC’s 2.Learn how.
Core Java Introduction Byju Veedu Ness Technologies httpdownload.oracle.com/javase/tutorial/getStarted/intro/definition.html.
CS101: Introduction to Computer Science Slides adapted from Sedgewick and Wayne Copyright © Your First Java.
1 TOPIC 1 INTRODUCTION TO COMPUTER SCIENCE AND PROGRAMMING Topic 1 Introduction to Computer Science and Programming Notes adapted from Introduction to.
CPS 100, Spring COMPSCI 100, Spring 2009 Owen Astrachan
CS 106 Introduction to Computer Science I 01 / 22 / 2007 Instructor: Michael Eckmann.
Today… “Hello World” ritual. Brief History of Java & How Java Works. Introduction to Java class structure. But first, next slide shows Java is No. 1 programming.
How to execute Program structure Variables name, keywords, binding, scope, lifetime Data types – type system – primitives, strings, arrays, hashes – pointers/references.
Lecture1 Instructor: Amal Hussain ALshardy. Introduce students to the basics of writing software programs including variables, types, arrays, control.
CS 106 Introduction to Computer Science I 01 / 22 / 2008 Instructor: Michael Eckmann.
CPS 100e 5.1 Inheritance and Interfaces l Inheritance models an "is-a" relationship  A dog is a mammal, an ArrayList is a List, a square is a shape, …
CS 177 Recitation Week 1 – Intro to Java. Questions?
ITP 109 Week 2 Trina Gregory Introduction to Java.
Programming for Interactivity Professor Bill Tomlinson Tuesday & Wednesday 6:00-7:50pm Fall 2005.
Sung-Dong Kim, Dept. of Computer Engineering, Hansung University Java - Introduction.
Introduction CMSC 202 Fall Instructors Mr. Ryan Bergeron – Lecture Section 01 Tues/Thu 1:00 – 2:15 am, Sondheim 111 – Lecture Section 04 Tues/Thu.
CSC 241: Introduction to Computer Science I
Lecture 1b- Introduction
Chapter No. : 1 Introduction to Java.
CompSci 6 Introduction to Computer Science
CS-0401 INTERMEDIATE PROGRAMMING USING JAVA
CSC 142 Introduction to Java [Reading: chapters 1 & 2]
Introduction to Computer Science I.
Program Design and Analysis II Professor: Jeffrey Forbes
COMPSCI 100, Spring 2008 Owen Astrachan
CSC 241: Introduction to Computer Science I
Presentation transcript:

CompSci 100e1.1 Welcome! Program Design and Analysis II for Engineers CompSci 100E Soc Psy 126 W, F 2:50-4:05 Professor Jeff Forbes

CompSci 100e1.2 Computer Science in a Nutshell?

CompSci 100e1.3 Computer Science in a Nutshell?

CompSci 100e1.4 Computer Science in a Nutshell?

CompSci 100e1.5 Computer Science in a Nutshell? l What is Computer Science? l What are some of the subfields of CS? l What does a Computer Scientist do? Lots of scientists and engineers l What does a programmer do?

CompSci 100e1.6 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

CompSci 100e1.7 Programming != Computer Science l What is the nature of intelligence? How can one predict the performance of a complex system? What is the nature of human cognition? Does the natural world 'compute'? l It is the interplay between such fundamental challenges and the human condition that makes computer science so interesting. The results from even the most esoteric computer science research programs often have widespread practical impact. Computer security depends upon the innovations in mathematics. Your Google search for a friend depends on state-of-the-art distributed computing systems, algorithms, and artificial intelligence.

CompSci 100e1.8 Course Overview l Active Lectures, Labs, Quizzes, Programs  Labs based on questions given out in previous week Hands-on practice with programming Discuss answers, answer new questions More opportunities for questions to be answered.  Active Lectures based on readings, questions, programs In-class questions used to ensure understanding  Programs Theory and practice of data structures and OO programming Fun, practical, tiring, … l Exams/Tests  Semester: open book/note*  Final: open book/note

CompSci 100e1.9 Is this course for you? l You should already know…  Basics of programming: variables, conditionals, loops, arrays/lists/vectors  Prereq: CompSci 6, EGR 53, AP CS, Programming experience, or ambition, … l Don’t need to know  Java, but some already do l This course introduces  Java & Object Oriented Programming  Data structures and abstraction  Algorithm design and analysis  The awesome ability to write programs to solve your problems and amaze your peers

CompSci 100e1.10 What’s this course really about? l Solving problems  Understanding problem statements  Designing solutions to the problems  Implementing the problem solution in a program  Understanding and testing the results  Documenting and presenting our results l How will we do it?  Written classwork and homework  Programming projects  Algorithmic Programming Testing

CompSci 100e1.11 Tradeoffs Simple, elegant, quick, efficient: what are our goals in programming? Don’t worry about getting it right the first time. How do we decide what tradeoffs are important? Tension between generality, simplicity, elegance, … Fast programs, small programs,. Runtime, space, your time, CPU time… Time vs. space Programming, design, algorithmic, data- structural

CompSci 100e1.12 Duke Contributions

CompSci 100e1.13 Story Anyway, I thought you'd be interested to know that in 2 of the 5 technical interviews I had, I recognized problems from CS courses at Duke. Specifically, they asked me to write algorithms for the "intersection of two sets" problem and a variation of the "boggle" problem. I thought that was pretty interesting. … For what it's worth for any of your students interviewing, I prepared for the interview mostly by practicing APT problems from the Duke CS100 course page, and I felt that that prepared me very well for about 80% of the questions that were asked. It certainly helped me get into the mindset of the types of things they ask, especially after a few years of being away from those types of algorithms. - Duke CS ‘07 alum

CompSci 100e1.14 Languages l Machine languages. l Natural languages. l High-level programming languages. [ real newspaper headlines, compiled by Rich Pattis ] Instead of imagining that our main task is to instruct a computer what to do, let us concentrate rather on explaining to human beings what we want a computer to do. - Donald Knuth n Kids Make Nutritious Snacks. n Red Tape Holds Up New Bridge. n Police Squad Helps Dog Bite Victim. n Local High School Dropouts Cut in Half. Pictures Natural language (English) Pseudo-code Specific high-level programming language Machine Language More easily expressed More precise © Sedgewick & Wayne

CompSci 100e1.15 Why Java? l Java features.  Widely used.  Widely available.  Embraces full set of modern abstractions.  Variety of automatic checks for mistakes in programs. l Java economy.  Mars rover.  Cell phones.  Blu-ray Discs.  Web servers.  Medical devices.  Supercomputing. …… James Gosling © Sedgewick & Wayne

CompSci 100e1.16 Why Java? l Java features.  Widely used.  Widely available.  Embraces full set of modern abstractions.  Variety of automatic checks for mistakes in programs.  Buzzword-enabled “Java is a simple, object-oriented, distributed, interpreted, robust, secure, architecture-neutral, portable, high performance, multi-threaded, and dynamic language” l Caveat. No perfect language. l Our approach.  Minimal subset of Java.  Develop general programming skills that are applicable to: C, C++, C#, Perl, Python, Ruby, Matlab, Fortran, Fortress, …

CompSci 100e1.17 Programming in Java l Programming in Java.  Create the program by typing it into a text editor, and save it as HelloWorld.java HelloWorld.java /******************************************* * Prints "Hello, World" * Everyone's first Java program. *******************************************/ public class HelloWorld { public static void main(String[] args) { System.out.println("Hello, World"); } © Sedgewick & Wayne

CompSci 100e1.18 Programming in Java l Programming in Java.  Create the program by typing it into a text editor, and save it as HelloWorld.java  Compile it using Eclipse or by typing at the command-line: javac HelloWorld.java  This creates a Java bytecode file named: HelloWorld.class command-line % javac HelloWorld.java (or click the Save button in Eclipse) © Sedgewick & Wayne

CompSci 100e1.19 Java Bytecode \0 \0 \0. \0 035 \n \0 006 \0 017 \t \0 020 \0 021 \b \0 022 \n \0 023 \ \ \ \ \0 003 ( ) V 001 \0 004 C o d e 001 \0 017 L i n e N u m b e r T a b l e 001 \0 004 m a i n 001 \0 026 ( [ L j a v a / l a n g / S t r i n g ; ) V 001 \0 \n S o u r c e F i l e 001 \0 017 H e l l o W o r l d. j a v a \f \0 007 \0 \b 007 \ \f \0 030 \ \0 \f H e l l o, W o r l d 007 \0 032 \f \0 033 \ \0 \n H e l l o W o r l d 001 \0 020 j a v a / l a n g / O b j e c t 001 \ j a v a / l a n g / S y s t e m \0 003 o u t 001 \0 025 L j a v a / i o / P r i n t S t r e a m ; 001 \ j a v a / i o / P r i n t S t r e a m 001 \0 007 p r i n t l n 001 \ ( L j a v a / l a n g / S t r i n g ; ) V \0 ! \0 005 \0 006 \0 \0 \0 \ \0 002 \0 001 \0 007 \0 \b \0 001 \0 \t \0 \0 \ \0 001 \0 001 \0 \0 \0 005 * 267 \ \0 \0 \ \0 \n \0 \0 \0 006 \0 001 \0 \0 \0 \f \0 \t \ \0 \f \0 001 \0 \t \0 \0 \0 % \0 002 \0 001 \ \0 \0 \t 262 \ \ \0 \0 \ \0 \n \0 \0 \0 \n \0 002 \0 \0 \0 017 \0 \b \ \0 001 \0 \r \0 \0 \0 002 \ HelloWorld.class © Sedgewick & Wayne

CompSci 100e1.20 A Rich Subset of the Java Language Primitive Numeric Types != ==>=<= <>-- / + % - ++ * Integer.parseInt() Double.parseDouble() Parsing Math.max()Math.min() Math.pow()Math.sqrt() Math.PIMath.abs() Math.log() Math.sin() Math Library Math.exp() Math.cos()System.out.println() System.out.print() System.out.printf() System for if Flow Control while else ! || true Boolean && false ;, ( { Punctuation ) } a[i] new a.length Arrays matches()charAt() length() + String compareTo() "" booleanchar long int Built-In Types String double equals()toString() main()new public class Objects private static © Sedgewick & Wayne

CompSci 100e1.21 Problem Solving and Programming l How many words are in a file?  What’s a word?  What’s a file?  How do we solve this: simply, quickly, …? What’s the best we can do? Constraints? l How many different/unique words are in a file?  How is this related to previous task? l How many words do two files have in common?  Spell-checking, stemming, Did you mean..? l How many codons does DNA have in common?

CompSci 100e1.22 Problem 1: Text Clouds l Text clouds: A simple yet powerful idea  Visualization of most frequently occurring words within some body of text  Great visual/statistic:  mat=tagcloud mat=tagcloud What information is stored in the URL of the NYTimes site above?  Color or font size indicates word frequency l What is involved with generating text clouds?  Steps? Issues?  See SimpleWordCount.java and SimpleCloudMaker.java

CompSci 100e1.23 Problem 2: Data processing l Scan a large (~ 10 7 bytes) file l Print the words together with counts of how often they occur l Need more specification? l How do you do it? l What is we only wanted the top k (say 20) words?

CompSci 100e1.24 Possible solutions 1. Use heavy duty data structures (Knuth)  Hash tries implementation  Randomized placement  Lots o’ pointers  Several pages 2. UNIX shell script (Doug Mclroy) tr -cs “[:alpha:]” “[\n*]” < FILE | \ sort | \ uniq -c | \ sort -n -r -k 1,1 3. See SimpleWordCount.java Which is better?  K.I.S.?