CS503: First Lecture, Fall 2008 Michael Barnathan.

Slides:



Advertisements
Similar presentations
Analysis of Algorithms
Advertisements

Discrete Structures CISC 2315
Lecture: Algorithmic complexity
CSE 373: Data Structures and Algorithms Lecture 5: Math Review/Asymptotic Analysis III 1.
HST 952 Computing for Biomedical Scientists Lecture 10.
Algorithmic Complexity Nelson Padua-Perez Bill Pugh Department of Computer Science University of Maryland, College Park.
Fall 2006CENG 7071 Algorithm Analysis. Fall 2006CENG 7072 Algorithmic Performance There are two aspects of algorithmic performance: Time Instructions.
CSE332: Data Abstractions Lecture 2: Math Review; Algorithm Analysis Tyler Robison Summer
CSE332: Data Abstractions Lecture 2: Math Review; Algorithm Analysis Dan Grossman Spring 2010.
CS305/503, Spring 2009 Introduction Michael Barnathan.
CS 206 Introduction to Computer Science II 09 / 10 / 2008 Instructor: Michael Eckmann.
Introduction to Analysis of Algorithms
Complexity Analysis (Part I)
Analysis of Algorithms. Time and space To analyze an algorithm means: –developing a formula for predicting how fast an algorithm is, based on the size.
CS107 Introduction to Computer Science
© 2006 Pearson Addison-Wesley. All rights reserved6-1 More on Recursion.
Cmpt-225 Algorithm Efficiency.
CS 206 Introduction to Computer Science II 09 / 05 / 2008 Instructor: Michael Eckmann.
Complexity (Running Time)
CS 206 Introduction to Computer Science II 01 / 28 / 2009 Instructor: Michael Eckmann.
Elementary Data Structures and Algorithms
CS2336: Computer Science II
1 Section 2.3 Complexity of Algorithms. 2 Computational Complexity Measure of algorithm efficiency in terms of: –Time: how long it takes computer to solve.
Analysis of Algorithms COMP171 Fall Analysis of Algorithms / Slide 2 Introduction * What is Algorithm? n a clearly specified set of simple instructions.
DAST, Spring © L. Joskowicz 1 Data Structures – LECTURE 1 Introduction Motivation: algorithms and abstract data types Easy problems, hard problems.
Search Lesson CS1313 Spring Search Lesson Outline 1.Searching Lesson Outline 2.How to Find a Value in an Array? 3.Linear Search 4.Linear Search.
Abstract Data Types (ADTs) Data Structures The Java Collections API
Algorithm Analysis (Big O)
CSE373: Data Structures and Algorithms Lecture 4: Asymptotic Analysis Aaron Bauer Winter 2014.
CSC 201 Analysis and Design of Algorithms Lecture 03: Introduction to a CSC 201 Analysis and Design of Algorithms Lecture 03: Introduction to a lgorithms.
Chapter 2.6 Comparison of Algorithms modified from Clifford A. Shaffer and George Bebis.
Week 2 CS 361: Advanced Data Structures and Algorithms
Recursion, Complexity, and Searching and Sorting By Andrew Zeng.
Discrete Mathematics Algorithms. Introduction  An algorithm is a finite set of instructions with the following characteristics:  Precision: steps are.
1 Chapter 24 Developing Efficient Algorithms. 2 Executing Time Suppose two algorithms perform the same task such as search (linear search vs. binary search)
{ CS203 Lecture 7 John Hurley Cal State LA. 2 Execution Time Suppose two algorithms perform the same task such as search (linear search vs. binary search)
Data Structures and Algorithms Lecture 5 and 6 Instructor: Quratulain Date: 15 th and 18 th September, 2009 Faculty of Computer Science, IBA.
Recursion, Complexity, and Sorting By Andrew Zeng.
Chapter 12 Recursion, Complexity, and Searching and Sorting
Analysis of Algorithms
© 2011 Pearson Addison-Wesley. All rights reserved 10 A-1 Chapter 10 Algorithm Efficiency and Sorting.
Algorithm Efficiency and Sorting Data Structure & Algorithm.
Chapter 10 Algorithm Analysis.  Introduction  Generalizing Running Time  Doing a Timing Analysis  Big-Oh Notation  Analyzing Some Simple Programs.
CSE373: Data Structures and Algorithms Lecture 3: Math Review; Algorithm Analysis Lauren Milne Summer 2015.
CSE373: Data Structures and Algorithms Lecture 3: Math Review; Algorithm Analysis Nicki Dell Spring 2014.
1 Algorithms  Algorithms are simply a list of steps required to solve some particular problem  They are designed as abstractions of processes carried.
Module #7: Algorithmic Complexity Rosen 5 th ed., §2.3.
CS 206 Introduction to Computer Science II 09 / 18 / 2009 Instructor: Michael Eckmann.
Asymptotic Notations By Er. Devdutt Baresary. Introduction In mathematics, computer science, and related fields, big O notation describes the limiting.
CS 206 Introduction to Computer Science II 01 / 30 / 2009 Instructor: Michael Eckmann.
Algorithm Analysis (Big O)
27-Jan-16 Analysis of Algorithms. 2 Time and space To analyze an algorithm means: developing a formula for predicting how fast an algorithm is, based.
CS 150: Analysis of Algorithms. Goals for this Unit Begin a focus on data structures and algorithms Understand the nature of the performance of algorithms.
E.G.M. PetrakisAlgorithm Analysis1  Algorithms that are equally correct can vary in their utilization of computational resources  time and memory  a.
David Evans Class 15: P vs. NP (Smiley Puzzles and Curing Cancer) CS150: Computer Science University of Virginia Computer.
1 Ch. 2: Getting Started. 2 About this lecture Study a few simple algorithms for sorting – Insertion Sort – Selection Sort (Exercise) – Merge Sort Show.
A Introduction to Computing II Lecture 5: Complexity of Algorithms Fall Session 2000.
Ch03-Algorithms 1. Algorithms What is an algorithm? An algorithm is a finite set of precise instructions for performing a computation or for solving a.
GC 211:Data Structures Week 2: Algorithm Analysis Tools Slides are borrowed from Mr. Mohammad Alqahtani.
1 Algorithms Searching and Sorting Algorithm Efficiency.
Algorithmic Foundations COMP108 COMP108 Algorithmic Foundations Algorithm efficiency Prudence Wong.
CSE373: Data Structures and Algorithms Lecture 3: Math Review; Algorithm Analysis Linda Shapiro Winter 2015.
Algorithmic Foundations COMP108 COMP108 Algorithmic Foundations Algorithm efficiency Prudence Wong
Data Structures I (CPCS-204) Week # 2: Algorithm Analysis tools Dr. Omar Batarfi Dr. Yahya Dahab Dr. Imtiaz Khan.
Introduction to Analysis of Algorithms
CSE373: Data Structures and Algorithms Lecture 2: Math Review; Algorithm Analysis Dan Grossman Fall 2013.
Lecture 6 Efficiency of Algorithms (2) (S&G, ch.3)
Discrete Mathematics and its Applications
Estimating Algorithm Performance
Presentation transcript:

CS503: First Lecture, Fall 2008 Michael Barnathan

Welcome Who I am: – Michael Barnathan – First year teaching. – First year the course is being taught in Java. – I’ll do my best, but please do voice any concerns. What this course will be about: – Data Structures – Algorithms – Java Prereq:CS501B or equivalent Java experience. What I expect of you: – It’s like learning to play an instrument: – Come to class – don’t miss your “lessons”. – Keep programming on your own – “practice” Your goals: Let them guide your learning.

Syllabus It’s online.online We may need to vary things based on the small number of students in the class. Any changes will generally work in your favor: – More individual attention. – Less lecturing, more guiding. – Possibly no exams.

What are they? Data structures are models. – They are means of arranging data within your program. – Choosing the right arrangement can make your job easier! Algorithms are recipes. – For solving problems in general: Programming. Cooking. Driving. Solving math problems. Many other areas. – You don’t need a computer to execute them. – In fact, very often you are the one executing them: Following driving directions. Solving puzzles. Interacting with a program (such as the Guessing Game).

How do we measure them? Correctness: – Produces the correct answer given the correct input. “Halting”: – Stops after it does what it’s supposed to. – Doesn’t crash. Performance: – Time (e.g. CPU time) – Space (e.g. Memory) Development time – don’t overlook it. Complexity: – Is the solution simple, intuitive, easy to understand?

Tradeoffs As Computer Scientists, you will make many tradeoffs: – Space vs. time. – Space and time vs. complexity. – Everything vs. dev. time. “Optimization” of an algorithm takes time and effort. Making these tradeoffs wisely is what separates “good” from “great”.

Measuring Time and Space An abstract notion, not usually measured in seconds, but “units” that only have meaning relative to one another. – For example, “2” takes twice as long as “1”, but we have no idea how long “1” takes. We care only about the order of growth. – Not how long something takes. – Instead, how much longer it takes with more data. We’ll start with “Worst-case” analysis. – Murphy’s Law: assume that everything that can slow the algorithm down will. – The purpose of this is to find out the absolute longest amount of time / largest amount of space that an algorithm might use. There’s also a “best-case”, which assumes the opposite.

Big O notation. O(f(n)), where f(n) is some function; e.g.: – O(1)“Constant time” – O(log n)“Logarithmic” – O(n)“Linear” – O(n log n)“n log n” (less common: “Linearithmic”) – O(n^2)“Quadratic” – O(n^p)“Polynomial” – O(2^n)“Exponential” This only indicates the dominant term of the algorithm’s growth. – For example, the function 3n^2 + 10n + 5 is O(n^2). We don’t take constant terms into account. – y =.0001x^2 is worse than y = 10000x. – This is because as x gets large, the x^2 term will dominate. Therefore, even if algorithm B takes twice as long as algorithm A, they would still belong to the same complexity class. – There is no such thing as “O(2n)”; it’s just O(n). Constants are not counted. Best Worst

Big-O visualized

How bad is exponential time? This bad: O(n log n) O(2^n)

Optimality Unfortunately, exponential time is not always avoidable. Certain problems can’t be solved any faster. Thus, an “optimal” solution might not be fast… – It’s just the fastest one that can exist. The study of how quickly problems can be solved is called complexity theory. – We unfortunately won’t have time to cover it. – It will probably be covered in CS512, or you can look into it yourself. – There is a famous unsolved problem in this field known as “P=NP?” There’s a $1 million prize for solving it. But that’s because it’s an extremely difficult question.

The Guessing Game: Writing a simple Java program. Problem: – Guess a random number from 1 to 100. – Prompt the user to input guesses. – Print out whether the number is actually higher, lower, or equal to the user’s guess. – Repeat until the user guesses correctly. How would you do this in Java? – The answer is in Thursday’s notes.

Decomposition of the problem It helps to make problems simpler; to iteratively take them down to the level at which you can implement them. “Higher”/“Lower”/“Equal” translate into “if” comparisons between the number and the guess. “Repeat until…” usually means “use a loop”. “Prompt the user” means you’ll be using Java’s input facilities (hint: look up the Scanner class). Random numbers can be generated using Math.random(). When in doubt about how to use a class, consult the Java API documentation!

That’s all for now! The lesson: – Algorithmic thought exists outside of computer science. You can apply what you will learn in this class in many unexpected places. Next class: The guessing game, review of asymptotic analysis, arrays. We are half a class ahead of schedule, so we have more time to review. – If we can keep this up, we can explore some really interesting topics towards the end.