com ompsci ci 201 201 first d day
play

Com ompSci ci 201, 201, First D Day Susan Rodger January 10, - PowerPoint PPT Presentation

Com ompSci ci 201, 201, First D Day Susan Rodger January 10, 2019 Website: http://bit.ly/201spring2020 1/10/2020 CompSci 201, Spring 2020 1 Course Information Online Compsc sci/I /Int nter erne net: : http:/ ://bit it.ly/201s


  1. Com ompSci ci 201, 201, First D Day Susan Rodger January 10, 2019 Website: http://bit.ly/201spring2020 1/10/2020 CompSci 201, Spring 2020 1

  2. Course Information Online • Compsc sci/I /Int nter erne net: : http:/ ://bit it.ly/201s /201spring ing2020 2020 ak aka https://w ://www2.cs cs.duke.edu .edu/co /courses es/s /spr pring20/co /comps psci201/ • Sakai 1/10/2020 CompSci 201, Spring 2020 3

  3. A is for … • Algorithm • This course is: Data Structures + Algorithms • API • Using Libraries is the future 1/10/2020 CompSci 201, Spring 2020 5

  4. PFTD: Plan For the Day • Be able to articulate why 201 is the right course for you, in terms of being able to complete it with understanding • What are pre-requisites? • Be able to explain what work is expected, collaboration policies, exams, discussions, assignments, APTs • Why are you taking Compsci 201? 1/10/2020 CompSci 201, Spring 2020 6

  5. PFTD: Part II • Be able to read some Java programs and to analyze them by applying your knowledge of programming to Java programs • Analyze for understanding and prediction • Know what work you should complete before January 13, 15, and 16 • What is due, when is it due 1/10/2020 CompSci 201, Spring 2020 7

  6. What is Computer Science? “Our species needs, and deserves, a citizenry with minds wide awake and a basic understanding of how the world works.” -Carl Sagan 1/10/2020 CompSci 201, Spring 2020 8

  7. Algorithms and Data Structures 1/10/2020 CompSci 201, Spring 2020 9

  8. Course Staff • Teachi aching ng A Associa ciate: • Kate O'Hanlon • Teachi aching ng A Assis istant nts: : • Yongxin Tan, Carol Yang • Head U d UTAs As: • Belanie Nagiel, Megan Phibbons, Charles Lyu, Daniel Hwang • 26 26 UTAs: s see ee co cour urse w web ebsite 1/10/2020 CompSci 201, Spring 2020 10

  9. What is Computer Science? • Grou oups of of 2-4, Do NOT use a search engine • http://bit.ly/201spring20-0110-1 • How is this relevant to Compsci 201? • Tradeoffs in scaling Data Structures/Algorithms • WOTO 1/10/2020 CompSci 201, Spring 2020 12

  10. What is Computer Science? 3.5 billion snaps/day or 40,000 second 350 million photos to FB/day 100 million Instagram updates/day 5.6 billion Google searches/day 1/10/2020 CompSci 201, Spring 2020 13

  11. 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 1/10/2020 CompSci 201, Spring 2020 14

  12. What is Computer Science? • It is t the s study of auto tomati ting a algorith thmic p processe sses s that s scale ale • Long Division? • Updating Search Engine information? • Adding up a column of numbers? • Sending $$ via Venmo? • Updating your LinkedIn page? 1/10/2020 CompSci 201, Spring 2020 16

  13. Some Goals for 201 • Given a problem statement & a real data source, design, develop, debug, and test a Java program that uses appropriate standard libraries to efficiently solve the problem. • Write programs that effectively implement and use data structures such as: arrays, maps, linked lists, stacks, queues, trees, and graphs. 1/10/2020 CompSci 201, Spring 2020 17

  14. More Goals for 201 • Evaluate the time and space complexity of algorithms , especially algorithms that scale, using empirical and mathematical analysis. • Apply basic object-oriented design and programming principles in developing software 1/10/2020 CompSci 201, Spring 2020 18

  15. Who are you? 1/10/2020 CompSci 201, Spring 2020 19

  16. Latanya Sweeney I am a computer scientist with a long history of weaving technology and policy together to remove stakeholder barriers to technology adoption. My focus is on "computational policy" and I term myself a "computer (cross) policy" scientist. I have enjoyed success at creating technology that weaves with policy to resolve real-world technology-privacy clashes. http://latanyasweeney.org/ Identify 87% of US population using (dob,zip,gender). Prof. Government and Technology @ Harvard, instrumental in HIPAA because if de-identification work. Former CTO of the FTC 1/10/2020 CompSci 201, Spring 2020 28

  17. Code Interlude • First 2 201 J Java p a pro rogra gram m – maybe f first e t ever! • Use what you know • Make informed assumptions • When more time? Book, Internet, Friends, Brain • All ll code o onlin nline: w web ebsite and and G Git itLab • Browse, fork, clone, critique, … 1/10/2020 CompSci 201, Spring 2020 29

  18. What does Code do? WDCD 1/10/2020 CompSci 201, Spring 2020 32

  19. Understanding Repetition • When hen d does es lo loop ter erminate? • What takes es t time w e when t n this is c code execut ecutes es? 1/10/2020 CompSci 201, Spring 2020 33

  20. Java Variables and Types • Variab iables les: n name, t , type, va value ue • Primitives: int, double • wcount, start, end • Object: String, Scanner, HashSet • s, set, word • For r reach v ach variab iable/ le/objec ect: n name, t , type, , va value ue • What are the operations on these? 1/10/2020 CompSci 201, Spring 2020 34

  21. Understand and Explain • "kjv10. 10.txt" w " with 8 h 823,135 ,135 words, 3 , 34,027 u 027 unique ue • About one second to run on rodger laptop • Double le, T Triple le, Q , Quadrup uple le o original f inal file • Total # words different, # unique same • N words in "kjv10", 2N, 3N, 4N respectively • Run untim imes: 1, 1, 1.5 1.5, 2.0, 2.0, 2.5 2.5 -- -- pat attern s n simila ilar • How to justify empirical with analytical analysis? 1/10/2020 CompSci 201, Spring 2020 35

  22. From Analysis to Code • How to und understand ( (rea ead) and and c create ( (writ ite) • Read book, use Google? read book, ask • What book? See syllabus • Practice, practice, practice • We e will lo ill look a at a a hig high-le level t el today, m , more d det etails ails i in Dis iscussion M Mond nday and and L Lec ecture Wed edne nesday • Pre-discussion work 1/10/2020 CompSci 201, Spring 2020 36

  23. Java Types and Operations • Wha hat can an we e do wit ith int int and and d doub uble? • +,-,/ seen in code, many more • Initialize and update • Wha hat c can w an we e do wit ith HashSet? • .add(..), .contains(..), .size() • What c can w we do with h Scanner anner? • .hasNext(), .next(), .close() 1/10/2020 CompSci 201, Spring 2020 37

  24. Java Concepts and Conventions • Class sses a s and Objects • You invoke methods on … call functions on .. • Object dot method: set.add(..) or s.hasNext() or set.size() or … • Variab iable i le ident ntif ifier iers b begin w in with l lowercase l e let etter er • Class i ident ntif ifie iers b begin w in with u h uppercase l let etter • Statements end end in s in sem emi-colo lon, n, s statem ement ent b blocks crea eated ed b by brace ces: { {..} 1/10/2020 CompSci 201, Spring 2020 38

  25. WOTO http:// //bi bit.ly/2 /201spr pring20-01 0110 10-2 1/10/2020 CompSci 201, Spring 2020 39

  26. Understanding Java and Scale • Java is is an o an object-orient iented ed l lang ngua uage • More on classes and objects later • Primit itiv ive t e types: int int, d , double, c char ar, , boolean an, , … • Fast, small, values stored in memory • Arrays a are h homogene eneous us collectio ions ns • Like Python lists, Matlab array/vector • Once created, don’t grow, can hold primitives • Arra rrayList<>, S , Set<>, M Map<> a are c collec lectio ions ns • Dynamic, powerful, scale, no primitives 1/10/2020 CompSci 201, Spring 2020 40

  27. Analyzing Code, Algorithm • Wha hat file o ile of 1,00 1,000,000 00 s strings w will r ill res esult in in this his code e e execut ecuting ing m most q quick ckly ly? • Characteristics of file? Bottleneck of method? • Wha hat file o ile of 1,00 1,000,000 00 s strings w will r ill res esult in in this his code e e execut ecuting ing m most s slowly? 1/10/2020 CompSci 201, Spring 2020 41

  28. Tradeoffs • What l line e is “bottlenec leneck” in this c code/alg lgorit ithm hm? • How can we make this faster? • Why is Google so fast when searching? • Replace lace HashSet<..> wit ith h ArrayList<..> • Why does code still run? • Common API, valuable for programmer!! 1/10/2020 CompSci 201, Spring 2020 42

  29. Course Logistics • Please s e see c e course w websit ite f e for m most m mat ater eria ial/d l/dates es • Web: • http://bit.ly/201spring2020 • For gra r grades • Sakai: • Exa Exams: • February 14, April 3, April 30 (final) 1/10/2020 CompSci 201, Spring 2020 43

More recommend