230 likes | 363 Vues
Computer Science 61B Data Structures and Advanced Programming Lecture 1 – Introduction. 2003-08-25 Dan Garcia (www.cs.berkeley.edu/~ddgarcia) Kathy Yelick (www.cs.berkeley.edu/~yelick) inst.eecs.berkeley.edu/~cs61b/ www.ucwise.org 4 Handouts: notes, accounts, cheating, hw0.
E N D
Computer Science 61BData Structures and Advanced ProgrammingLecture 1 – Introduction 2003-08-25 Dan Garcia(www.cs.berkeley.edu/~ddgarcia) Kathy Yelick (www.cs.berkeley.edu/~yelick) inst.eecs.berkeley.edu/~cs61b/www.ucwise.org4 Handouts:notes, accounts, cheating, hw0
Course Goals "You will…" • Learn how to write great code • Understand abstraction • Design efficient data structures and algorithms that use them • Learn Java and object-oriented programming
Understanding Abstraction • Webster’s definition of abstraction: “Leaving out of consideration one or more qualities of a complex object so as to attend to others.” • Kinds of abstraction: • Procedural abstraction • I.e., functions in 61a, more of this in 61b • Data abstraction • Object model in 61a, a lot more in 61b • Iteration abstraction • Like map in 61a, more of this in 61b
Why Use Java? • Supports data abstraction and iteration abstraction • Programming in the large • Hides some details of the underlying machine • Memory management (malloc and free) • Programmer efficiency • Anectodal evidence says 2 more efficient than C++ • Not because: • One can safely download Java programs from others • It has lots of libraries for writing cool animations • It’s the #1 language for job openings in software
Object-Oriented Programming • Objects: some data and operations that manipulate that data • Classes: factories for "generating" objects • Methods: an operation on an object or a class • Variables: names for the data in objects, classes, and methods • Object-Oriented: uses data abstraction (classes) and inheritance
A Design Problem Connectivity matrix of the web (dot = a link from one page to another) • You've just been hired by Google. • They need a data structure to lookup pages by keywords • About 100M keywords • About 3 billion web pages; always growing • What data structure should you use? • What order do you rank the results? 0 Page-number 105 0 Page-number 105
Possible Solutions • From 61A: A linked list of keyword/URL pairs • Time: O(n) to lookup • A Binary Search Tree, keyed by keywords • Time: O(log n) to lookup, if balanced. • Can we ensure balance? (61b topic) • A sorted array of keywords, lookup using binary search (divide and conquer) • Time: O(log n) to lookup (61b topic) • A hash table • Time: O(1) to lookup (61b topic) • Note: big-O hides important factors in real performance (61b topic)
Administrivia • Our background • Remarkably similar • MIT undergrads (same dorm, even!) • MIT/Cal grads • Now both on Cal faculty. Research interests: • KY: Parallel computing (Using computers to understand the world) • DG: Combinatorial Game Theory, Graphics, Mac OS X Programming • Your background • Freshman / Sophomores / Juniors / Seniors / Grads • Who has taken 61A? E77? • Majors: EECS vs L&S vs others? • Own computers? PCs? Macs? • Scheme vs. Java?
Unauthorized Collaboration • Unauthorized collaboration (cheating) will: • be reported to the Office of Student Conduct • result in grade penalties (including failing the course). • Discussion about general solution strategies, or help debugging is encouraged. • No Code Rule: Never have a copy of someone else's program in your possession & never give your program to someone else. • If you receive a significant idea from someone, acknowledge it. • “someone” includes the web, students from previous semesters, your parents, old solutions, etc. • May still receive a 0, but protects you from academic misconduct. • These rules also apply to groups.
CA Governor's race What do folks think of the "Govenator"? A's franchise-first! First double-grand-slam in their history Tejada, Hernandez go yard Current Events
Texts • Introduction to Programming Using Java: An Object-Oriented Approach, 2nd Edition, by Arnow and Weiss. • Note that this book is currently not yet available in the bookstore (but we are told it will be in by Wednesday 2003-08-27). • Program Development in Java, by Liskov and Guttag, Chapters 4 and 10 only. • These two chapters are shrink-wrapped with the Arnow and Weiss book, if purchased through the campus bookstores. • Data Structures and Algorithms in Java (2nd Ed.) by Goodrich and Tamassia. • Reading assignments on course portal
Lecture : Peer Instruction • Increase real-time learning in lecture, test understanding of concepts vs. details • As complete a “segment” ask multiple choice question • 1-2 minutes to decide yourself, vote • 3 minutes in pairs to reach consensus. Teach others! Vote as a team. • 5-7 minute discussion of answers, questions, clarifications • How shall we record votes?
PRS and Lecture Format • PRS (Personal Response System) • Electronic devices sold in bookstore for $37.25 • Can use in other classes as Cal student • Can also sell back to bookstore for half-price and end • Room is wired with receivers -- every vote counts! • Typical 50-minute Lecture Format • 18-minute lec, 2-min admin break • 18-minute lec, 8-min Peer instruct, 4-min close Attention 20 min. Break Next-thing Time
FormatLecture - Discussion - Lecture - Lab - Lecture • There IS discussion and lab this week…
Homeworks, Labs and Projects • Lab exercises (every wk; due at worst first 1/2-hour next lab) • Homework exercises (~ every week) • First homework (HW 0) passed out today, due in section next week. • Projects (every ~4 weeks) • All exercises, reading, homeworks, projects on course portal: www.ucwise.org
Quiz, Midterm & Final • Quiz • In-class on Java basics • Midterm: Wed 7-9pm Nov 5th room TBA • Review: Sun Nov 2nd, 2pm Room TBA • Final:Tue 12:30-3:30pm Dec 18th • 1 week before Christmas, for everyone • No plane ticket excuse
Your Final Grade • Grading (probably won't change, but might) • 5% Labs • 10% Homework • 10% Project 1 • 12% Project 2 • 13% Project 3 • 8% Quiz • 17% Midterm • 25% Final • Grade distributions • Similar to CS61A, in the absolute scale. No curve! • Perfect score is 300 points. 10-20-10 for A+, A, A- • Similar for Bs and Cs (40 pts per letter-grade) • Differs: … C+, C, C-, D, F (No D+ or D- distinction) 50% Assignments 50% Exams
Extra Credit: EPA! • Effort • Attending office hours, completing all assignments • Participation • Attending lecture and voting using the PRS system • Asking great questions in discussion and lecture and making it more interactive • Altruism • Helping others in lab or on the newsgroup • EPA! extra credit points have the potential to bump students up to the next grade level!
TAs • David Parks [Head TA] • Igor Gammer • Rishi Kant • Ram Gudavalli
The “Hello, world” Program in Java /* In a file called HelloWorld.java */ public classHelloWorld { public static void main (String[] args){ System.out.println("Hello, world");} } • The HelloWorld class is a "factory" for HelloWorld objects. • The class knows how to do the "main" operation. • Calls the System class to get an output stream & does a print operation on it using the "Hello, world" string.
Anatomy of "Hello, World" in Java • The classes are: • HelloWorld • System • String • The objects are: • System.out, "Hello, world" • The methods are: • main (on the HelloWorld class) • println (on the OutputStream class)
Differences Between Java & Scheme • Everything in Java has a type, and you have to "declare" it. E.g.,int x = 1;vs.(let ((x 1)) ... ) • Java has a compiler & a non-interactive interpreter. program.c program.scm Program.java cc javac program eval eval Program.class run java answer answer answer Let's demonstrate!
And in Conclusion… • In CS61B you will… • Learn how to write great code • Understand abstraction • Design efficient data structures and algorithms that use them • Learn Java and object-oriented programming