CompSci 100 Prog Design and Analysis II

Slides:



Advertisements
Similar presentations
CS /29/2004 (Recitation Objectives) and Computer Science and Objects and Algorithms.
Advertisements

Computer Science - I Course Introduction Computer Science Department Boston College Hao Jiang.
COMP 14: Primitive Data and Objects May 24, 2000 Nick Vallidis.
1 An Extremely Short Introduction to Computer Programming Mike Scott.
Compsci 101, Spring COMPSCI 101, Spring 2012 Introduction to Computer Science Owen Astrachan
(c) University of Washingtonhashing-1 CSC 143 Java Hashing Set Implementation via Hashing.
CPS 100, Fall COMPSCI 100, Fall 2011 Owen Astrachan w/ Michael Hewner
CompSci 100e Program Design and Analysis II January 18, 2011 Prof. Rodger CompSci 100e, Spring20111.
CSCI 115 Computer Programming Overview. Computer Software System Software –Operating systems –Utility programs –Language compilers Application Software.
CPS 100, Spring COMPSCI 100, Spring 2010 Owen Astrachan
Compsci 06/101, Fall COMPSCI 06/101, Fall 2010 Owen Astrachan Robert Duvall
Introduction. 2COMPSCI Computer Science Fundamentals.
Chapter 1: Introducing JAVA. 2 Introduction Why JAVA Applets and Server Side Programming Very rich GUI libraries Portability (machine independence) A.
Lecture 2: Classes and Objects, using Scanner and String.
5-Aug-2002cse Arrays © 2002 University of Washington1 Arrays CSE 142, Summer 2002 Computer Programming 1
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.
CPS 100, Fall COMPSCI 100, Fall 2009 Owen Astrachan
CS 206 Introduction to Computer Science II 09 / 10 / 2009 Instructor: Michael Eckmann.
CompSci CompSci 6 Programming Design and Analysis I Dietolf (Dee) Ramm
CompSci 100E 1.1 CompSci 100E Dietolf (Dee) Ramm Robert A. Wagner
BEGINNING PROGRAMMING.  Literally – giving instructions to a computer so that it does what you want  Practically – using a programming language (such.
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.
CPS 100, Spring COMPSCI 100, Spring 2009 Owen Astrachan
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 23 Algorithm Efficiency.
CompSci 101 Introduction to Computer Science January 28, 2016 Prof. Rodger compsci101 spring161.
Compsci 06/101, Spring COMPSCI 06/101, Spring 2011 Introduction to Computer Science Owen Astrachan
Lecture 1 Data Structures Aamir Zia. Introduction Course outline Rules and regulations Course contents Good Programming Practices Data Types and Data.
CompSci 101 Introduction to Computer Science Sept 13, 2016 Prof. Rodger compsci101 fall161.
CompSci 4 Java 1 Apr 2, 2009 Prof. Susan Rodger. Announcements Assignment 7 questions? –Beware having two events that kick in at the same time! –Beware.
Using the Java Collection Libraries COMP 103 # T2
CompSci 100E cs. duke CompSci 100E Dietolf (Dee) Ramm
CSC 222: Object-Oriented Programming
CSC 222: Object-Oriented Programming
CSC 222: Computer Programming II
CSC207 Fall 2016.
JAVA MULTIPLE CHOICE QUESTION.
INTERMEDIATE PROGRAMMING WITH JAVA
CSC 321: Data Structures Fall 2016
Chapter No. : 1 Introduction to Java.
CSC 221: Computer Programming I Spring 2010
Building Java Programs
CompSci 100 Dietolf (Dee) Ramm
CompSci 6 Introduction to Computer Science
CSC 221: Computer Programming I Fall 2005
CSC 321: Data Structures Fall 2015
CSC 222: Object-Oriented Programming
CompSci 101 Introduction to Computer Science
Lecture 2 of Computer Science II
Namespaces, Scopes, Access privileges
CS Programming I Jim Williams, PhD.
Data Structures (CS212D) Overview & Review.
CompSci 101 Introduction to Computer Science
CompSci 101 Introduction to Computer Science
Introduction to Data Structures
EECE 310 Software Engineering
COMPUTER 2430 Object Oriented Programming and Data Structures I
Objective of This Course
Building Java Programs
Data Structures and Algorithms for Information Processing
Data Structures (CS212D) Overview & Review.
CompSci 1: Principles of Computer Science Lecture 1 Course Overview
Building Java Programs
CSC 321: Data Structures Fall 2018
Building Java Programs
COP3530- Data Structures Introduction
CS Week 2 Jim Williams, PhD.
Building Java Programs
CSCI 203: Introduction to Computer Science I
COMPSCI 100, Spring 2008 Owen Astrachan
CSC 241: Introduction to Computer Science I
Presentation transcript:

CompSci 100 Prog Design and Analysis II August 31, 2010 Prof. Rodger CompSci 100, Fall 2010

Announcements Recitations start this week on Thurs. and Fri. See Resources page Install Java, Eclipse, and Ambient Today is about introductions and getting started Assignment RSG out – on web page APTs out – on web page CompSci 100, Fall 2010

Data into Information and Knowledge Computer Science CompSci 100, Fall 2010

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 100, Fall 2010

What will you experience? CompSci 100, Fall 2010

Programming != Computer Science 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'? 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. http://www.post-gazette.com/pg/pp/04186/341012.stm CompSci 100, Fall 2010

Efficient design, programs, code Object-oriented design and patterns. Software design principles transcend language, but … Using the language: Java (or C++, or Python, or …), its idioms, its idiosyncracies Know data structures and algorithms. Trees, hashing, binary search, sorting, priority queues, greedy methods, graphs … Engineer, scientist: what toolkits do you bring to programming? Mathematics, design patterns, libraries --- standard and others…

Course Overview There are details, see the course web page Midterms and final are open book, what does that mean? APTs: Algorithmic Problem-solving and Testing Weekly small programming assignments, tested online Programming assignments: major, minor, paired, … Why should you come to class? Meet people, learn things, participate in a community Provide help, get help, wonder, dance, think Why is this course so great? Because you’re in it CompSci 100, Fall 2010

Who has taken Compsci 100? Jessica Abroms, Trinity ‘98 Pixar, iPhone, Guitar Hero Luis von Ahn, Trinity ‘00 Macarthur, reCaptcha, GWAP Rachel Zurer, Trinity ‘04 Americorps, Creative Writing Ge Wang, Trinity ’00 T-Pain, Ocarina, Music Jim Bungener, Pratt ’99 CFD, Team Alinghi Ted Hung, Trinity ‘02 Electronic Arts, Lucasarts CompSci 100, Fall 2010

Who takes CompSci100 now? CompSci 100, Fall 2010

What's in Compsci 100? Understanding tradeoffs: reasoning, analyzing, describing… Algorithms Data Structures Programming Design Programming using Java Tools: Eclipse, JDK, Libraries, … Ideas: Design Patterns, OOP, Agile programming, … Engineering and analyzing designs and programs Using mathematical and scientific techniques Scaling solutions CompSci 100, Fall 2010

What is this class about? The Organization of Data, and Searching CompSci 100, Fall 2010

Environment we will use Eclipse – an Integrated Development Environment Editor Compiler An output console Visualization of files and folders Submission of programs (Ambient) See CompSci 100 Resources page for installing Java, Eclipse and Ambient on your computer CompSci 100, Fall 2010

Questions If you gotta ask, you’ll never know Louis Armstrong: “What’s Jazz?” If you gotta ask, you ain’t got it Fats Waller: “What’s rhythm?” What questions did you ask today? Arno Penzias CompSci 100, Fall 2010

Tradeoffs Simple, elegant, quick, efficient: what are our goals in programming? What does XP say about simplicity? Einstein? Programming, design, algorithmic, data-structural Fast programs, small programs, run anywhere-at-all programs. Runtime, space-time, your time, CPU time… How do we decide what tradeoffs are important? Tension between generality, simplicity, elegance, …

From Blog to Scientific Visualization Text Cloud aka Tag Cloud? Number of occurrences/emphasis indicated by size of word Great visual/statistic: http://chir.ag/phernalia/preztags/ What is involved with generating tag clouds? Steps? Issues? See SimpleTagMaker.java CompSci 100, Fall 2010

Analysis of SimpleTagMaker Which classes used have static methods? Do methods in CSSMaker need to be non-static? Why? How would we create a tag cloud from a file of words? What steps are needed? Algorithmic? Java? Why is there an IOException that’s thrown from main? What is an exception, how do we handle them? Any questions? CompSci 100, Fall 2010

Problem Solving and Programming 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? How many different/unique words are in a file? How is this related to previous task? How many words do two files have in common? Spell-checking, Google did you mean ..? CompSci 100, Fall 2010

Fast, cheap, out-of-control? This is valid and correct Java code, questions? import java.util.*; import java.io.*; public class SimpleUnique { public static void main(String[] args) throws FileNotFoundException{ Scanner s = new Scanner(new File("/data/kjv10.txt")); String[] words = s.useDelimiter("\\Z").next().split("\\s+"); TreeSet<String> set = new TreeSet<String>(); set.addAll(Arrays.asList(words)); System.out.printf("total #: %d, unique #: %d\n", words.length,set.size()); } CompSci 100, Fall 2010

How fast is fast? How cheap is cheap? How do we measure how fast the code/design is? Can we implement this design in C++? Can we implement this in Python? We want a measure that’s independent of language? What are we measuring? How do we express answer? Units? Best case? Average? Worst? What is answer using recognized terminology? CompSci 100, Fall 2010

What is Computer Science? Computer science is no more about computers than astronomy is about telescopes. Edsger Dijkstra Computer science is not as old as physics; it lags by a couple of hundred years. However, this does not mean that there is significantly less on the computer scientist's plate than on the physicist's: younger it may be, but it has had a far more intense upbringing! Richard Feyneman http://www.wordiq.com CompSci 100, Fall 2010

Some Java Vocabulary and Concepts Java has a huge standard library Organized in packages: java.lang, java.util, javax.swing, … API browseable online, but Eclipse IDE helps a lot Java methods have different kinds of access inter/intra class Public methods … Private methods … Protected and Package methods … Primitive types (int, char, double, boolean) are not objects but everything else is literally an instance of class Object foo.callMe(); CompSci 100, Fall 2010

Solving problems, writing code APT: Simple Word Game Understand the problem, know how to solve an instance Ideas? Caveats? Writing code to implement proposed solution Will it run? In time? Constraints? Look before you code How will we test the solution? When to start testing? What’s the green dance and when do we do it? Satisfaction of finishing something Knowing when to stop when you’re not making progress Leveraging community wisdom CompSci 100, Fall 2010

Structuring Information: ideas & code Is an element in an array, Where is an element in an array? DIY: use a loop Use Collections, several options Tradeoffs? public boolean contains(String[] list, String target){ for(String s : list){ if (s.equals(target)) return true; } return false; public boolean contains(String[] list, String target){ return Arrays.asList(list).contains(target); } public boolean contains(String[] list, String target){ return new HashSet<String>(Arrays.asList(list)).contains(target); } CompSci 100, Fall 2010

Basic data structures and algorithms Arrays are typed and fixed in size when created Don't have to fill the array, but cannot expand it Can store int, double, String, Object, … ArrayList (and related interface List) grows s needed Stores objects, not primitives Autoboxing in Java 5 facilitates int to/from Integer conversion Store an int in an ArrayList, get one out Can’t convert entire ArrayList to array for int, can for String, why? ArrayList objects grow themselves intelligently java.util package has lots of data structures and algorithms Use rather than re-implement, but know how do to do both CompSci 100, Fall 2010

Who is Alan Perlis? It is easier to write an incorrect program than to understand a correct one Simplicity does not precede complexity, but follows it If you have a procedure with ten parameters you probably missed some If a listener nods his head when you're explaining your program, wake him up Programming is an unnatural act Won first Turing award http://www.cs.yale.edu/homes/perlis-alan/quotes.html

Computer Science in a Nutshell CompSci 100, Fall 2010