VE281 Data Structures and Algorithms. Introduction and Asymptotic Algorithm Analysis

Similar documents
COMP251: Algorithms and Data Structures. Jérôme Waldispühl School of Computer Science McGill University

COMP Data Structures

CS 241 Data Organization using C

COMP Data Structures

Algorithms and Data Structures

Algorithms and Data Structures

CS503 Advanced Programming I CS305 Computer Algorithms I

Syllabus COSC-051-x - Computer Science I Fall Office Hours: Daily hours will be entered on Course calendar (or by appointment)

Beijing Jiaotong University CS-23: C++ Programming Summer, 2019 Course Syllabus

COMP Analysis of Algorithms & Data Structures

CSCE 441 Computer Graphics Fall 2018

San José State University Computer Science Department CS49J, Section 3, Programming in Java, Fall 2015

EECE.2160: ECE Application Programming Spring 2017

EECE.2160: ECE Application Programming Spring 2019

Data Structures and Algorithms

Algorithms and Data Structures

CoSci 440 SYLLABUS Programming in C++ INSTRUCTOR Mari Rettke cell SECTION : and 13345

Announcements. 1. Forms to return today after class:

CS 241 Data Organization. August 21, 2018

Data Structures and OO Development II

San José State University Department of Computer Science CS-144, Advanced C++ Programming, Section 1, Fall 2017

Partha Sarathi Mandal

San José State University Department of Computer Science CS049J, Programming in Java, Section 2, Fall, 2016

BOSTON UNIVERSITY Metropolitan College MET CS342 Data Structures with Java Dr. V.Shtern (Fall 2011) Course Syllabus

CSC 111 Introduction to Computer Science (Section C)

CS 240 Fall 2015 Section 004. Alvin Chao, Professor

CSCE 210/2201 Data Structures and Algorithms. Prof. Amr Goneid

CSCE 210/2201 Data Structures and Algorithms. Prof. Amr Goneid. Fall 2018

CS 0449 Intro to Systems Software Fall Term: 2181

CMSC 132: Object-Oriented Programming II. Administrivia

CSE 114, Computer Science 1 Course Information. Spring 2017 Stony Brook University Instructor: Dr. Paul Fodor

CPSC 211, Sections : Data Structures and Implementations, Honors Final Exam May 4, 2001

CS2013 Course Syllabus Spring 2018 Lecture: Mon/Wed 2:00 P.M. 2:50 P.M. SH C259 Lab: Mon/Wed 2:50 P.M. 4:00 P.M. SH C259

Welcome to CSL 201 Data Structures

Data Structures and Algorithms

CMPE012 Computer Engineering 12 (and Lab) Computing Systems and Assembly Language Programming. Summer 2009

Course Syllabus - CNT 4703 Design and Implementation of Computer Communication Networks Fall 2011

Programming Languages CSCE

CS/ENGRD 2110 Object-Oriented Programming and Data Structures Spring 2012 Thorsten Joachims

Rochester Institute of Technology Golisano College of Computing and Information Sciences Department of Information Sciences and Technologies

CISC 3130 Data Structures Spring 2018

Introduction to UNIX

Introduction to Programming System Design CSCI 455x (4 Units)

INFSCI 1017 Implementation of Information Systems Spring 2017

Overview. CSE 101: Design and Analysis of Algorithms Lecture 1

Object-Oriented Programming CSCI-UA

Oklahoma State University Institute of Technology Face-to-Face Common Syllabus Fall 2017

ESET 349 Microcontroller Architecture, Fall 2018

Course and Contact Information. Course Description. Course Objectives

San José State University College of Science/Department of Computer Science CS 152, Programming Language Paradigms, Section 03/04, Fall, 2018

BLM2031 Structured Programming. Zeyneb KURT

Advanced Algorithms and Data Structures

Computer Science II Data Structures

You must pass the final exam to pass the course.

Advanced Programming Concepts. CIS 15 : Spring 2007

San José State University Computer Science Department CS157A: Introduction to Database Management Systems Sections 5 and 6, Fall 2015

San José State University Department of Computer Science CS-144, Advanced C++ Programming, Section 1, Spring 2018

CISC 3130 Data Structures Fall 2018

Welcome to CSE 326: Data Structures & Algorithms

Web Programming Fall 2011

Course Administration

CS535: Interactive Computer Graphics

San José State University Department of Computer Science CS-174, Server-side Web Programming, Section 2, Spring 2018

CS 240 Fall Mike Lam, Professor. Just-for-fun survey:

San Jose State University College of Science Department of Computer Science CS151, Object-Oriented Design, Sections 1, 2, and 3, Spring 2018

Introduction to Data Structures

CSE 417 Practical Algorithms. (a.k.a. Algorithms & Computational Complexity)

MPATE-GE 2618: C Programming for Music Technology. Syllabus

San Jose State University College of Science Department of Computer Science CS151, Object-Oriented Design, Sections 1,2 and 3, Spring 2017

Course and Contact Information. Course Description. Course Objectives

Welcome to... CS113: Introduction to C

Dr. Angela Guercio Dr. Natalia Dragan. Spring 2011

COLLEGE OF DUPAGE CIS 2542 Advanced C++ with Data Structure Applications Course Syllabus

Introduction to Computers & Programming

CS 3270 Mobile Development for Android Syllabus

COURSE SYLLABUS ****************************************************************************** YEAR COURSE OFFERED: 2015

CS 200, Section 1, Programming I, Fall 2017 College of Arts & Sciences Syllabus

CS/ENGRD 2110 Object-Oriented Programming and Data Structures Spring 2012 Thorsten Joachims. Lecture 25: Review and Open Problems

CS 375 UNIX System Programming Spring 2014 Syllabus

CSc 2310 Principles of Programming (Java) Jyoti Islam

ECE Introduction to Compilers and Translation Engineering

San José State University Department of Computer Science CS151, Object Oriented Design, Section 04, Fall, 2016 (42968)

Syllabus CS 301: Data Structures Spring 2015

Class Note #02. [Overall Information] [During the Lecture]

CARTO UNIVERSITY GROUP. Syllabus GEO 445/545 Computer-assisted Cartography Winter December 18, 2013

Advanced Algorithms and Data Structures

Home Works and Assignments

Design and Analysis of Algorithms. Comp 271. Mordecai Golin. Department of Computer Science, HKUST

Virtual University of Pakistan

Cleveland State University

Compulsory course in Computer Science

Data Structures and Algorithms

Outline. Logistics. Logistics. Principles of Software (CSCI 2600) Spring Logistics csci2600/

CSC2100-Data Structures

Object-Oriented Programming for Managers

Outline. Computer Science 331. Course Information. Assessment. Contact Information Assessment. Introduction to CPSC 331

CS 3030 Scripting Languages Syllabus

COMP-202C: Foundations of Programming

Introduction to Computer Networking

CSCI 434 INTRODUCTION TO LOCAL AREA NETWORKS (SPRING 2015)

Transcription:

VE281 Data Structures and Algorithms Introduction and Asymptotic Algorithm Analysis

Time and Location Time: Tuesday 10:00-11:40 am, Thursday 10:00-11:40 am. Location: Dong Xia Yuan 200 2

Instructor Weikang Qian Email: qianwk@sjtu.edu.cn Phone: 3420-4020 Office: Room 119, JI Building Office hour Tuesday 2:00 3:00 pm Friday 2:00 3:00 pm Or by appointment 3

Teaching Assistants Hu, Sheng Email: husheyn@gmail.com Cell phone: 18801966647 Office hour: TBD Tang, Biman Email: every.elva@gmail.com Cell phone: 15216714434 Office hour: TBD 4

Textbooks for Reference (Not Required) Data Structures and Algorithm Analysis, by Clifford Shaffer. Online available: http://people.cs.vt.edu/~shaffer/book/c++3e20120605.pdf Data Structures and Algorithms with Object-Oriented Design Patterns in C++, by Bruno Preiss. Online available: http://www.brpreiss.com/books/opus4/html/book.html Algorithms, by S. Dasgupta, C. Papadimitriou, and U. Vazirani. Online available: http://www.cs.berkeley.edu/~vazirani/algorithms.html Introduction to Algorithms, 3 rd edition, by Thomas Cormen et al., MIT Press, 2009. 5

Grading Composition In class quizzes: 5% 3~4 written assignments: 15% 3~4 programming assignments: 30% Midterm exam: 20% Final exam: 30% We will curve the final grades, if necessary. Questions about the grading? Must be mentioned to the instructor or the TAs within one week after receiving the item. 6

Programming Assignments We require you to develop your programs on Linux operating systems using compiler g++. We will grade your programs in the Linux environment: they must compile and run correctly on this operating system. 7

Assignment Deadline Each written assignment must be turned in before class on each due date. Each programming assignment (PA) must be turned in by 11:59 pm on the due date to be accepted for full credit. However, we still allow you to submit your PA within 3 days after the due date, but there is a late penalty. Hours Late Scaling Factor (0, 24] 80 % (24, 48] 60 % (48, 72] 40 % No PA will be accepted if it is more than 3 days late! 8

Assignment Deadline In very occasional cases, we accept deadline extension request. Deadline extension requests will only be considered if you contact the course instructor in person. Do not contact TAs! ONLY be granted for documented medical or personal emergencies that could not have been anticipated. NOT granted for reasons such as accidental erasure/loss of files and outside conflicting commitments. 9

Some Suggestions Taking notes in class is a good idea. Start doing the homework early! Back up your code frequently in case your computer crashes. 10

Exams Written exams. Some problems may ask you to write codes on the paper. Closed book and closed notes. No electronic devices are allowed. These include laptops and cell phones. 11

12 Collaboration and Cheating You must do all the assignments yourself. You may not discuss the specifics of your solution with anyone other than TAs and instructor. Some behaviors that are considered as cheating: Having someone else write your assignment, in whole or in part. Copying another student s answer/code, in whole or in part. Reading another student s answer/code. Having a copy of another student s answer/code. Using test cases of another student. Testing your code with another student s account. Another student includes a student in the current semester or in the previous semester.

Collaboration and Cheating Any suspect of cheating will be reported to the Honor Council at JI. For programming assignments, we will run an automated test to check for unusually similar programs. Those that are similar to the extent that they appear to be derived from the same code base - in whole or in part - will be reported to the Honor Council at JI. 13

The Result of Confirmed Cheating Typical result based on the experience of Ve280 in Summer 2013: Reduction of the grade for that assignment to zero, plus Reduction of the final grade for the course by one grade point, e.g., B+ C+ 14

Sakai Log into Sakai: http://202.120.46.147/portal Check the class webpage on the Sakai regularly for Announcements Slides Assignments 15

Getting Help If you have questions, come to see TAs and instructor during the office hour! We will hardly answer your questions through email, because it is inefficient. 16

17 Prerequisite Ve280 Programming and Elementary Data Structures is required. Compiling and debugging on Linux operating systems C++ programming Recursion Pointers and arrays Structs and enums I/O streams, including file I/O Abstract data types and classes Dynamical memory management Template and polymorphism Knowledge of Discrete Mathematics (Ve203) is a plus.

References and Copyright Slides used (modified when necessary) Sugih Jamin, University of Michigan Sartaj Sahni, University of Florida Bert Huang, Columbia University Tim Roughgarden, Stanford University Clifford Shaffer, Virginia Tech 18

Data Structures and Algorithms Data structures is concerned with the representation and manipulation of data. All programs manipulate data. So, all programs represent data in some way. Example: linked list first 19

Logical versus Physical Form Data items have both a logical and a physical form. Logical form: definition of the data item within an abstract data type (ADT). Example: Integers in mathematical sense: +, - Physical form: implementation of the data item within a data structure. Example: 32 bit integers. 20

Data Structure Example: Linked List Logical Form first Physical Form class IntList { node *first; public:... }; struct node { node *next; int value; }; 21 next: value: 4 next: value: next: 2 value: 3

Data Structures and Algorithms Data manipulation requires an algorithm a sequence of steps that solves a specific task. Data structures + Algorithms = Programs The study of data structures and algorithms is fundamental to Computer Science. 22

Real World Problem: Navigation Finding the shortest route from Shanghai to Suzhou 23

Real World Problem: Navigation What information do we need? Streets. Intersections of streets. (We assume that our departure place and destination are at certain intersections.) How do we store the information in computer? Graph: consisting of nodes and edges. Each edge has a weight to denote the distance between two nodes. 5 2 1 3 24

Real World Problem: Navigation The algorithm: finding the shortest path from a source node (A) to a sink node (B). A 5 2 1 3 B 25

Challenges: Efficiency For a small number of nodes, we can enumerate all the possible paths. A 5 C 2 1 D 3 B Path A C B: 8; Path A D C B: 6; The minimum is 6. 26

Challenges: Efficiency However, in real world, the graph is much more complicated. It is impossible to enumerate all the possible paths! How can we solve the problem? 27

More about Efficiency Choice of data structures or algorithms can make the difference between a program running in a few seconds or many days. Example: Number of comparisons for linear search and binary search (Worst Case) 28 Input Size Linear Binary Ratio (L/B) 64 64 6 10.7 128 128 7 18.3 256 256 8 32 512 512 9 56.9 1024 1024 10 102.4

More about Efficiency A solution is said to be efficient if it solves the problem within its resource constraints. Space, i.e. memory consumption Time Our major concern The cost of a solution is the amount of resources that the solution consumes. We value efficiency of the data structures and algorithms! We will learn how to analyze their efficiency. 29

Course Objectives Learn the tool: Common data structures and algorithms And their efficiency Apply the tool Solve a problem using existing data structures and algorithms. Choose the right tool: some tools are better for certain tasks than other tools. Do performance analysis. 30

Topics Asymptotic algorithm analysis Data structures Linked list, stacks, and queues Trees, including binary search tree Hash table Heaps Graphs Algorithms Graph-related algorithms, such as minimum spanning tree, shortest path Divide and conquer Dynamic programming 31

32 Questions?

33 Asymptotic Algorithm Analysis

How to Measure Efficiency? Empirical comparison: run programs Use the wall-clock time to measure the runtime Empirical comparison could be tricky. It depends on Compiler Machine (CPU speed, memory, etc.) CPU load Asymptotic Algorithm Analysis For most algorithms, running time depends on the size of the input. Running time is expressed as T(n) for some function T on input size n. 34

Input Dependency: Example Summing an array of n elements // REQUIRES: a is an array of size n // EFFECTS: return the sum int sum(int a[], unsigned int n) { int result = 0; for(unsigned int i = 0; i < n; i++) result += a[i]; return result; } The runtime is cn, where c is some constant. With n fixed, any array has roughly the same runtime. 35

Best, Worst, Average Cases 36 In the example of summing an array, all inputs of a given size take the same time to run. However, in some other cases, this is not true, i.e., not all inputs of a given size take the same time to run. Example: linear search // REQUIRES: a is an array of size n // EFFECTS: return the index of the element // equals key. If no such element, return n. int search(int a[], unsigned int n, int key) { } for(unsigned int i = 0; i < n; i++) if(a[i] == key) return i; return n;

Exercises What is the best case for linear search? Data is found in the first place you look. What is the worst case? Data is found in the last place. Or data is not found. What is the average case? Average performed over all possible inputs of a given size. 37

Best, Worst, Average Cases Best case: least number of steps required, given the ideal input Worst case: most number of steps required, given the most difficult input. Average case: average number of steps required, given any input. 38

Which Case to Use? Average case or worst case is common. While average time appears to be the fairest measure, it may be difficult to determine. Sometime, it requires domain knowledge, e.g., the distribution of inputs. Worst case is pessimistic, but it gives an upper bound. Bonus: worst case usually easier to analyze. 39