CPS 100, Fall 2011 1.1 COMPSCI 100, Fall 2011 Owen Astrachan w/ Michael Hewner

Slides:



Advertisements
Similar presentations
COMP 121 Week 9: AbstractList and ArrayList. Objectives List common operations and properties of Lists as distinct from Collections Extend the AbstractCollection.
Advertisements

CS /29/2004 (Recitation Objectives) and Computer Science and Objects and Algorithms.
Computer Science - I Course Introduction Computer Science Department Boston College Hao Jiang.
COMP 14: Primitive Data and Objects May 24, 2000 Nick Vallidis.
Java Software Solutions Lewis and Loftus Chapter 2 1 Copyright 1997 by John Lewis and William Loftus. All rights reserved. Software Concepts -- Introduction.
Compsci 101, Spring COMPSCI 101, Spring 2012 Introduction to Computer Science Owen Astrachan
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.
1 CSC 221: Computer Programming I Fall 2004 course overview  what did we set out to learn?  what did you actually learn?  where do you go from here?
(c) University of Washingtonhashing-1 CSC 143 Java Hashing Set Implementation via Hashing.
1 CSC 427: Data Structures and Algorithm Analysis Fall 2011 See online syllabus (also available through BlueLine): Course goals:
CompSci 100e Program Design and Analysis II January 18, 2011 Prof. Rodger CompSci 100e, Spring20111.
Java: Chapter 1 Computer Systems Computer Programming II.
CPS 100, Spring COMPSCI 100, Spring 2010 Owen Astrachan
Compsci 06/101, Fall COMPSCI 06/101, Fall 2010 Owen Astrachan Robert Duvall
CSC 212 Object-Oriented Programming and Java Part 1.
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 Object Oriented Programming Basics of Java Language MBY.
Introduction Algorithms and Conventions The design and analysis of algorithms is the core subject matter of Computer Science. Given a problem, we want.
CS 11 java track: lecture 1 Administrivia need a CS cluster account cgi-bin/sysadmin/account_request.cgi need to know UNIX
Lecture 2: Classes and Objects, using Scanner and String.
Basics of Java IMPORTANT: Read Chap 1-6 of How to think like a… Lecture 3.
CSE 143 Lecture 2 More ArrayList ; classes and objects reading: 10.1; slides created by Marty Stepp and Hélène Martin
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
Chapter 2 Introducing Interfaces Summary prepared by Kirk Scott.
CS 206 Introduction to Computer Science II 09 / 10 / 2009 Instructor: Michael Eckmann.
Compsci 06/101, Fall What will you do in Compsci 6 Today? l Learn about selection and if/else statements  In context of solving problems  Understanding.
1 CSC 222: Object-Oriented Programming Spring 2013 Course goals:  To know and use basic Java programming constructs for object- oriented problem solving.
1 CSC 321: Data Structures Fall 2013 See online syllabus (also available through BlueLine2): Course goals:  To understand.
How to Read Code Benfeard Williams 6/11/2015 Susie’s lecture notes are in the presenter’s notes, below the slides Disclaimer: Susie may have made errors.
CompSci CompSci 6 Programming Design and Analysis I Dietolf (Dee) Ramm
CSC 212 – Data Structures Lecture 37: Course Review.
Compsci 6/101, Spring More on Python, Tools, Compsci 101 l APTs, Assignments, Tools  APT: Algorithmic Problem-solving and Testing  How to get.
CompSci 100E 1.1 CompSci 100E Dietolf (Dee) Ramm Robert A. Wagner
Fall 2015CISC124 - Prof. McLeod1 CISC124 Have you filled out the lab section survey? (As of last night 54 left to fill out the survey.) TA names have been.
Stacks and Queues. 2 3 Runtime Efficiency efficiency: measure of computing resources used by code. can be relative to speed (time), memory (space), etc.
1 CS 177 Week 12 Recitation Slides Running Time and Performance.
BEGINNING PROGRAMMING.  Literally – giving instructions to a computer so that it does what you want  Practically – using a programming language (such.
CPS 100, Spring Tools: Solve Computational Problems l Algorithmic techniques  Brute-force/exhaustive, greedy algorithms, dynamic programming,
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.
Data Structures and Algorithms Dr. Tehseen Zia Assistant Professor Dept. Computer Science and IT University of Sargodha Lecture 1.
1 CSC 221: Computer Programming I Spring 2008 course overview  What did we set out to learn?  What did you actually learn?  Where do you go from here?
1 CSC 427: Data Structures and Algorithm Analysis Fall 2006 See online syllabus (also available through Blackboard): Course goals:
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
90-723: Data Structures and Algorithms for Information Processing Copyright © 1999, Carnegie Mellon. All Rights Reserved. 1 Lecture 1: Introduction Data.
CPS 100, Spring COMPSCI 100, Spring 2009 Owen Astrachan
CompSci 100e2.1 Today’s Topics l Reading:  Sedgewick & Wayne: , l Topics  APTs  Basic Collections: ArrayLists: the expandable array.
Programmeren 1 6 september 2010 HOORCOLLEGE 2: INTERACTIE EN CONDITIES PROGRAMMEREN 1 6 SEPTEMBER 2009 Software Systems - Programming - Week.
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.
Written by: Dr. JJ Shepherd
Compsci 6/101, Spring PFTW: Functions, Control, Python/Tools l How do functions work and why do we use them?  Functions we call (APIs), Functions.
Compsci 06/101, Spring COMPSCI 06/101, Spring 2011 Introduction to Computer Science Owen Astrachan
Coming up Implementation vs. Interface The Truth about variables Comparing strings HashMaps.
CompSci 100 Prog Design and Analysis II
Using the Java Collection Libraries COMP 103 # T2
CompSci 100E cs. duke CompSci 100E Dietolf (Dee) Ramm
INTERMEDIATE PROGRAMMING WITH JAVA
CSC 321: Data Structures Fall 2017
CSC 221: Computer Programming I Spring 2010
CompSci 100 Dietolf (Dee) Ramm
CompSci 6 Introduction to Computer Science
CSC 221: Computer Programming I Fall 2005
CompSci 101 Introduction to Computer Science
Introduction to Data Structures
Unit 3 Test: Friday.
Data Structures and Algorithms for Information Processing
CSC 321: Data Structures Fall 2018
COMPSCI 100, Spring 2008 Owen Astrachan
Presentation transcript:

CPS 100, Fall COMPSCI 100, Fall 2011 Owen Astrachan w/ Michael Hewner

CPS 100, Fall Data into Information and Knowledge Computer Science

CPS 100, Fall What can you do with Compsci?

CPS 100, Fall What can you do with Compsci?

CPS 100, Fall What can you do with Compsci?

CPS 100, Fall What can you do with Compsci?

CPS 100, Fall What can you do with Compsci?

CPS 100, Fall What can you do with Compsci?

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

CPS 100, Fall What will you experience?

CPS 100, Fall 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.

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

CPS 100, Fall Course Overview l There are details, see the course web pagecourse 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: solo, paired, … l Why should you come to class?  Meet people, learn things, participate in a community  Provide help, get help, wonder, dance, think  Participate in graded exercises that affect your final grade l Why is this course so great?  Because you’re in it

CPS 100, Fall What's in Compsci 100? l Understanding tradeoffs: reasoning, analyzing, describing…  Algorithms  Data Structures  Programming  Design l 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

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

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

CPS 100, Fall Language

CPS 100, Fall From Blog to Scientific Visualization l Text Cloud aka Tag Cloud?  Number of occurrences/emphasis indicated by size of word  Great visual/statistic: l What is involved with generating tag clouds?  Steps? Issues?  We will look at code to generate the tag cloud, but we'll look at simpler code first

CPS 100, Fall

CPS 100, Fall 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, Google did you mean..?

CPS 100, Fall Fast, cheap, out-of-control? l 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")); s.useDelimiter("\\Z"); String all = s.next(); String[] words = all.split("\\s+"); TreeSet set = new TreeSet (); set.addAll(Arrays.asList(words)); System.out.printf("total #: %d, unique #: %d\n", words.length,set.size()); } total #: , unique #: 34027

CPS 100, Fall Pythonic WordCounting This is valid and correct Python code, questions? def countWords(filename): file = open(filename) str = file.read() words = str.split() unique = set(words) print "filename: ", filename print "total # words = ",len(words) print "unique # words = ",len(unique) countWords('/data/kjv10.txt') filename: /data/kjv10.txt total # words = unique # words = 34027

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

CPS 100, Fall What is Computer Science? l Computer science is no more about computers than astronomy is about telescopes. Edsger Dijkstra l 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

CPS 100, Fall Some Java Vocabulary and Concepts l Java is a (statically) typed language  Every variable/object has a type that's defined at compile time (compare Python)  More typing, but more errors caught before runtime l Java is an object-oriented language  All code is in a class and all code inside function/method  Classes are also types, so variables/objects extendible  We will see interfaces and inheritance later  Classes have instance variables, methods local variables l Java has different 'types' primitive and Object/class. This is for efficiency, but it's sometimes confusing

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

CPS 100, Fall Solving problems, writing code l APT: AccessLevel APT: AccessLevel  Understand the problem, know how to solve an instance  Ideas? Caveats? l 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? l 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

CPS 100, Fall Structuring Information: ideas & code l 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 (Arrays.asList(list)).contains(target); }

CPS 100, Fall Basic data structures and algorithms l 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, … l 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

CPS 100, Fall Who is Alan Perlis? l It is easier to write an incorrect program than to understand a correct one l Simplicity does not precede complexity, but follows it l If you have a procedure with ten parameters you probably missed some l If a listener nods his head when you're explaining your program, wake him up l Programming is an unnatural act l Won first Turing award

CPS 100, Fall Analysis of StaticSimpleWords.java l How are variables used?  What types are there, definitions, re-used variables,  What is a File, a Scanner, a String[], a HashSet, a … l How are strings and values printed?  What is System.out? How is it used? l Why is there a FileNotFoundException thrown from main?  What is an exception, how do we handle them? l How are statements organized, how is whitespace used?

CPS 100, Fall Who takes Compsci 100 Now?