15-121 Introduction to Data Structures Lecture #1 Introduction 28 August 2019 Margaret Reid-Miller
Today Course Administration Overview of Course A (very basic) Java introduction Course website: www.cs.cmu.edu/~mrmiller/15-121 Fall 2018 15-121 (Reid-Miller) 2
Me Margaret Reid-Miller mrmiller@cs.cmu.edu Gates 6003, x 8-2640 I am an Assistant Teaching Professor CS Upperclass Academic Advisor What to call me? Margaret, please Fall 2018 15-121 (Reid-Miller) 3
Our Teaching Assistants Section A: Stephanie Ananth (sananth) Office Hours: 5:30pm-7:30pm Wednesday 3:00pm-5:00pm Sunday Section B: Darien Weems (dweems) Office Hours: 4:00pm-7:00pm Thursday 5:00pm-7:00pm Sunday Rooms to be determined Fall 2018 15-121 (Reid-Miller) 4
You Take 15-121 if you are an IS major (most of you), or if you don t plan to take another CS course. Take 15-122 if you are a CS or ECE major or minor, or plan to take more CS classes. Let s find out who s who (and how badly I pronounce your names ) Fall 2018 15-121 (Reid-Miller) 5
Formally: 15-112 Prerequisites In practice, you will need: Laptop or desktop computer The Java JDK and an editor or IDE Dr. Java (only runs Java 6 on Mac) Eclipse Standard Fall 2018 15-121 (Reid-Miller) 6
Introduction to Data Structures Data structures are ways to organize and store data and perform operations on the data efficiently. Create/understand algorithms Analyze algorithms (time/space efficiency) Which data structure we use will depend on What operations we expect to perform often on our data. What the performance tradeoffs are for access/update. Efficient algorithms are essential with big data (Think Google, database, Amazon, Facebook, ) This course provides a foundation for organizing large data sets for efficiency Fall 2018 15-121 (Reid-Miller) 7
Introduction to Data Structures This course provides a foundation for organizing large data sets for efficiency. Two parts: Conceptual information about various data structures How to use and implement those data structures in your programs. We assume you know how to write programs using fundamental programming concepts (variables, Booleans, conditional, loops, functions, lists, Fall 2018 15-121 (Reid-Miller) 8
Course logistics Course website: www.cs.cmu.edu/~mrmiller/15-121 Lectures: No electronic devices without prior permission (you re here to learn Data Structures) Bring notebook, paper, and pens/pencils to class every day. I often ask you to write code, and often will ask you to turn in what you write. Ask lots of questions (It helps your classmates who are equally curious and it gives me feedback.) Fall 2018 15-121 (Reid-Miller) 9
Course elements Lectures - notes posted to website after class Recitation labs 5% Participation 5% Quizzes 5% Homework 30% 2 Midterms 30%: 15% each Final 25% Fall 2018 15-121 (Reid-Miller) 10
Wednesday Recitations 5% In the computer lab (BH 140E) There will be weekly labs of short exercises. Only 10 count towards your grade. You must attend and participate to get credit. You may work collaboratively. Submitting after class will not be accepted. Tomorrow s recitation, though, will be a lecture! Fall 2018 15-121 (Reid-Miller) 11
Participation 5% You must attend lectures, ask questions, and do in-class exercises. If you miss a couple of days of class, you may still earn 100% for participation. If you miss class half the time, you will earn 0% for participation. Fall 2018 15-121 (Reid-Miller) 12
Quizzes 5% There will be short unannounced quizzes, approximately weekly. Tests the previous week s work. We will drop you lowest TWO quizzes. There will be no make-up quizzes for any reason. Fall 2018 15-121 (Reid-Miller) 13
2 Written Midterms 15% each During class on. No makeup exams except by prior approval by me for medical or family emergencies pre-arranged university-approved absences Fall 2018 15-121 (Reid-Miller) 14
During final exams. Final Exam 25% We will not proctor the final exam prior to the registrar scheduled exam, so do not leave Pittsburgh until after the last day of finals (makeup day). Fall 2018 15-121 (Reid-Miller) 15
Homework 30% There will be weekly homework assignments that include a written portion and programming. Due Monday(?) nights at 11:59pm. You are allowed up to 3 late days total without penalty, with a maximum of 1 late day per assignment. No credit will be given for late work after you have used up all your late days. Fall 2018 15-121 (Reid-Miller) 16
Academic Integrity You must do your own work. Discussion with other students is limited to clarifying the assignments or at a high noncode level (pictures). If you need help, ask the course staff or me. You should never look at another person s program nor allow another student to look at your program. Fall 2018 15-121 (Reid-Miller) 17
Most Common Cheating Strong student finishes assignment Weak student is working just before it is due. Asks for help from strong student Provides line-by-line coaching or provides solution Strong student goes to sleep Weak student turns in work by strong student Both students end up crying in my office Where did they go wrong? Fall 2018 15-121 (Reid-Miller) 18
What if I cheat on a assignment? Record a negative score on the assignment. Reduce your final semester letter grade. Prevent you from dropping, withdrawing, or changing to pass/fail. Send letters to Student Affairs, your advisor, various deans, etc. May result in long-term suspension. Fall 2018 15-121 (Reid-Miller) 19
Today ü Course Administration Overview of Course A (very basic) Java introduction Fall 2018 15-121 (Reid-Miller) 20
Course Topics Java, Objects, Arrays, ArrayLists, Efficiency Linked Lists, Recursion, Big-O Interfaces, Iterators, Stacks & Queues Searching & Sorting, Trees, BSTs, Recursion Sets & Maps, Hashing, Priority Queues, Heaps, Graphs, Review & Final Exam Fall 2018 15-121 (Reid-Miller) 21
Today ü Course Administration ü Overview of Course A (very basic) Java introduction Fall 2018 15-121 (Reid-Miller) 22
Program Translation Compiler - program that translates code in a highlevel source language, all at once, into low-level object or target language. E.g., translates Java to byte code. The code is translated only once and executed many times. Interpreter - program that translates and then executes only one (or several) statement(s) at a time. E.g., Python translates each time a statement is executed. Fall 2018 15-121 (Reid-Miller) 23
Traditional Compilation Different hardware/operating systems need slight variants of the program and separate compilers. Source Source code Source code code code compile Machine code Machine code Machine code Machine code Windows Intel Linux HP Linux IBM Mac OS X imac Fall 2018 15-121 (Reid-Miller) 24
Java Translation Java compiles to a single virtual machine. Game.java Game.class Compile JVM JVM JVM JVM Windows Intel Linux HP Interpret (or compile) Linux IBM Mac OS X imac JVM - Java Virtual Machine Fall 2018 15-121 (Reid-Miller) 25
Types of Programming Errors Compile-time error- Syntax errors found by the compiler or syntax-aware editors. e.g., x - * y = Run-time error - Error causes program to stop abnormally; often called an exception. e.g., x = y / z (What if z is zero?) Logical error - Program produces incorrect results without complaint. e.g., Sort program does not always sort the data Fall 2018 15-121 (Reid-Miller) 26
Java program structure Every Java program consists of one or more classes: Each class contains methods: Each method contains the statements (instructions) to be executed. The program starts its execution at the method called main and follows the instructions in the order specified. Fall 2018 15-121 (Reid-Miller) 27
Java Classes Java programs contain one or more classes, which are the basic units of code. The basic form of a Java class is at follows: Same name as the file name public class <name> { <method> <method> Keywords are in purple <method> } Fall 2018 15-121 (Reid-Miller) 28
The main method Every Java program must have a method named main of the form method header public static void main (String[] args) { } <statement> <statement> <statement> grouping characters The program execution starts at the main method. Fall 2018 15-121 (Reid-Miller) 29
A simple program /* * Prints three lines to the console. */ public class DreamDisplayer { Comments } public static void main(string[] args) { System.out.println("When I grow up... "); System.out.println(); // blank line } System.out.print("I want to be "); System.out.println( an astronaut."); println newline at end. print no newline System.out where to find the method. OUTPUT: When I grow up... Statements end with semicolons I want to be an astronaut. Fall 2018 15-121 (Reid-Miller) 30