CS 380 ALGORITHM DESIGN AND ANALYSIS

Similar documents
Algorithm Design and Analysis. What is an Algorithm? Do Algorithms Matter?

Thomas H. Cormen Charles E. Leiserson Ronald L. Rivest. Introduction to Algorithms

Virtual University of Pakistan

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

CS 161 Fall 2015 Final Exam

Review of course COMP-251B winter 2010

Data Structures and Algorithm Analysis in C++

END-TERM EXAMINATION

SUGGESTION : read all the questions and their values before you start.

Introduction to Algorithms Third Edition

Chapter 1 Introduction

5105 BHARATHIDASAN ENGINEERING COLLEGE

Design and Analysis of Algorithms CS404/504. Razvan Bunescu School of EECS.

4.1.2 Merge Sort Sorting Lower Bound Counting Sort Sorting in Practice Solving Problems by Sorting...

CS6402 DESIGN AND ANALYSIS OF ALGORITHMS QUESTION BANK UNIT I

Lecture 3, Review of Algorithms. What is Algorithm?

Ph.D. Written Examination Syllabus

What Is An Algorithm? Algorithms are the ideas behind computer programs. An algorithm is the thing which stays the same whether

Algorithms and Data Structures (INF1) Lecture 15/15 Hua Lu

Chapter 1 Divide and Conquer Algorithm Theory WS 2014/15 Fabian Kuhn

1 Format. 2 Topics Covered. 2.1 Minimal Spanning Trees. 2.2 Union Find. 2.3 Greedy. CS 124 Quiz 2 Review 3/25/18

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

Lecture 1. Introduction

CAD Algorithms. Categorizing Algorithms

Mathematical Thinking

Faculty of Science FINAL EXAMINATION COMP-250 A Introduction to Computer Science School of Computer Science, McGill University

Solutions to Exam Data structures (X and NV)

CLASS: II YEAR / IV SEMESTER CSE CS 6402-DESIGN AND ANALYSIS OF ALGORITHM UNIT I INTRODUCTION

INSTITUTE OF AERONAUTICAL ENGINEERING

Department of Computer Applications. MCA 312: Design and Analysis of Algorithms. [Part I : Medium Answer Type Questions] UNIT I

D.K.M.COLLEGE FOR WOMEN (AUTONOMOUS), VELLORE-1.

DESIGN AND ANALYSIS OF ALGORITHMS

Chapter 5. Divide and Conquer. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

L.J. Institute of Engineering & Technology Semester: VIII (2016)

Review for Midterm Exam

What is an algorithm? CISC 1100/1400 Structures of Comp. Sci./Discrete Structures Chapter 8 Algorithms. Applications of algorithms

Ch5. Divide-and-Conquer

Anany Levitin 3RD EDITION. Arup Kumar Bhattacharjee. mmmmm Analysis of Algorithms. Soumen Mukherjee. Introduction to TllG DCSISFI &

Algorithms and Data Structures, or

9. The expected time for insertion sort for n keys is in which set? (All n! input permutations are equally likely.)

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Question Bank Subject Name: CS6402- Design & Analysis of Algorithm Year/Sem : II/IV UNIT-I INTRODUCTION

CISC 1100: Structures of Computer Science

Midterm CSE 21 Spring 2012

CSci 231 Final Review

Ph.D. Comprehensive Examination Design and Analysis of Algorithms

Your favorite blog : (popularly known as VIJAY JOTANI S BLOG..now in facebook.join ON FB VIJAY

CSE 100: B+ TREE, 2-3 TREE, NP- COMPLETNESS

looking ahead to see the optimum

Sankalchand Patel College of Engineering - Visnagar Department of Computer Engineering and Information Technology. Assignment

AP Computer Science 4325

ECE250: Algorithms and Data Structures Final Review Course

CSCE 321/3201 Analysis and Design of Algorithms. Prof. Amr Goneid. Fall 2016

( ) n 3. n 2 ( ) D. Ο

Chapter 1 Divide and Conquer Algorithm Theory WS 2013/14 Fabian Kuhn

5. DIVIDE AND CONQUER I

Part I Basic Concepts 1

Chapter 1 Divide and Conquer Algorithm Theory WS 2015/16 Fabian Kuhn

ECE 250 Algorithms and Data Structures

Chapter 9 Graph Algorithms

logn D. Θ C. Θ n 2 ( ) ( ) f n B. nlogn Ο n2 n 2 D. Ο & % ( C. Θ # ( D. Θ n ( ) Ω f ( n)

11/22/2016. Chapter 9 Graph Algorithms. Introduction. Definitions. Definitions. Definitions. Definitions

Divide-and-Conquer. Combine solutions to sub-problems into overall solution. Break up problem of size n into two equal parts of size!n.

The Algorithm Design Manual

Contents. CS 124 Final Exam Practice Problem 5/6/17. 1 Format and Logistics 2

CSE 202 Divide-and-conquer algorithms. Fan Chung Graham UC San Diego

What is an Algorithm?

THE DESIGN AND ANALYSIS OF COMPUTER ALGORITHMS

CS1800 Discrete Structures Fall 2016 Profs. Aslam, Gold, Ossowski, Pavlu, & Sprague December 16, CS1800 Discrete Structures Final

15CS43: DESIGN AND ANALYSIS OF ALGORITHMS

Lecture 2: Algorithm Analysis

University of Waterloo Department of Electrical and Computer Engineering ECE 250 Algorithms and Data Structures

PATH FINDING AND GRAPH TRAVERSAL

CS 206 Introduction to Computer Science II

PSD1A. DESIGN AND ANALYSIS OF ALGORITHMS Unit : I-V

Computer Science Spring 2005 Final Examination, May 12, 2005

Lecture 13. Reading: Weiss, Ch. 9, Ch 8 CSE 100, UCSD: LEC 13. Page 1 of 29

CS 4100 // artificial intelligence

Computer Algorithms CISC4080 CIS, Fordham Univ. Instructor: X. Zhang Lecture 1

Computer Algorithms CISC4080 CIS, Fordham Univ. Acknowledgement. Outline. Instructor: X. Zhang Lecture 1

Algorithms Interview Questions

COT 5407: Introduction to Algorithms. Giri Narasimhan. ECS 254A; Phone: x3748

( ) + n. ( ) = n "1) + n. ( ) = T n 2. ( ) = 2T n 2. ( ) = T( n 2 ) +1

COMPUTING SUBJECT KNOWLEDGE AUDIT

Sorting. Sorting. Stable Sorting. In-place Sort. Bubble Sort. Bubble Sort. Selection (Tournament) Heapsort (Smoothsort) Mergesort Quicksort Bogosort

Letter STUDENT NUMBER ALGORITHMICS (HESS) Written examination. Monday 31 October 2016

Design and Analysis of Algorithms 演算法設計與分析. Lecture 7 April 15, 2015 洪國寶

Lecture 18. What we ve done and what s to come

n 2 ( ) ( ) + n is in Θ n logn

Reference Sheet for CO142.2 Discrete Mathematics II

The Limits of Sorting Divide-and-Conquer Comparison Sorts II

LECTURE NOTES OF ALGORITHMS: DESIGN TECHNIQUES AND ANALYSIS

CSE 373: Data Structures and Algorithms


Algorithms and Data Structures

CS 4800: Algorithms & Data. Lecture 1 January 10, 2017

r=1 The Binomial Theorem. 4 MA095/98G Revision

MergeSort, Recurrences, Asymptotic Analysis Scribe: Michael P. Kim Date: April 1, 2015

/633 Introduction to Algorithms Lecturer: Michael Dinitz Topic: Sorting lower bound and Linear-time sorting Date: 9/19/17

Algorithms and Data Structures. Algorithms and Data Structures. Algorithms and Data Structures. Algorithms and Data Structures

6. Algorithm Design Techniques

Transcription:

CS 380 ALGORITHM DESIGN AND ANALYSIS Lecture 1: Course Introduction and Motivation Text Reference: Chapters 1, 2 Syllabus Book Schedule Grading: Assignments/Projects/Exams/Quizzes Policies Late Policy Grade Complaints Website: zeus.cs.pacificu.edu/lanec/cs380s17 1

Overview Topics: Data structures Complexity classes (Big Oh, etc) Sorting (insertion sort, mergesort, quicksort) Searching (binary search trees, red-black trees, hash tables) Graphs (depth-first, breadth-first, spanning trees, shortest paths) Strings (radix sorting, substring search) Proofs Methods Divide and conquer Greedy algorithms Backtracking Dynamic Programming What is an Algorithm? A sequence of computational steps that transforms the input into the desired output. To be interesting, an algorithm has to solve a general, specified problem. An algorithmic problem is specified by describing the set of instances that it must work on and the desired properties of the output. 2

History of Algorithms 1600 BC: integer factorization - Babylonians 300 BC: Euclid s algorithm 1400: Substitution Ciphers 1936: Turing machine 1942: Fast Fourier Transform 1945: Merge Sort: John von Neumann 1952: Huffman Coding 1956: Bellman Ford 1956: Kruskal s algorithm 1959: Dijkstra s algorithm 1960: Karatsuba multiplication 1962: Quicksort 1964: Heapsort 1968: A* algorithm 1972: Red-black/B trees 1973: RSA encryption 1998: Google s PageRank 1998: rsynch Why study algorithms? Internet: Google PageRank, Google maps, packet routing Biology: Human Genome Project Social Networks: advertisements, data mining File Compression: MP3, JPG, etc. Finance: Trading algorithms (must be FAST!) Business: Inventory management, flight scheduling, recommendation systems (Amazon, Netflix) Computer Graphics: CGI, video games Security: Encryption, RSA, MD5, SHA-1 3

Internet: Google PageRank Human Genome Project 4

Human Genome Project Following subsequence has 7 CAG repeats: TTTTCTTTTA CAGTTTCAGT TTTCAGCAGT TTTTTCAGTT TTTCAGTTGT CAGTTTGGCT Repeats Diagnosis 0-9 not human 11-29 normal 30-39 high risk 40-180 Huntington's disease 181 - not human Note: Human genome has approximately 4 billion base pairs, and Chromosome 4 has approximately 190 million base pairs. Finance: Algorithmic Trading 5

Nasdaq Trading Algo_trader Reddit AMA: Real quantitative trading operations need practical algorithmic edge. They're not looking for comp sci geeks that know 20 languages and all the dark corners of computing languages. We only need people that can produce algorithmic trading edge. Of course to do that you need experience, ability to understand and create algorithms, relevant languages, strong understanding of statistics, and some combination of signal processing, data mining, and/or linear algebra. Any applicant able to demonstrate a true algorithmic trading edge, or the ability to create and/or understand such edge can get a job, internship or at least some kind of research collaboration. 6

Recommendation Systems Computer Graphics: Matrix Multiplication https://www.youtube.com/watch?v=smanlptmawe 7

Video Games: Scene Creation http://www.adriancourreges.com/blog/2015/11/02/gta-v-graphics-study/ Image Compression: SVD 8

Image compression: SVD, cont. rank=2 rank=5 rank=10 rank=50 original Pathfinding 9

Pathfinding Algorithms https://qiao.github.io/pathfinding.js/visual/ Performance Algorithms is the study of computer-program performance What is more important than performance in computer programs? 10

Correctness For any algorithm, we must prove that it always returns the desired output for all legal instances of the problem. What does this mean for sorting? Induction and Recursion Mathematical induction is a very useful method for proving the correctness of recursive algorithms. Recursion and induction are the same basic idea: (1) basis case, (2) general assumption, (3) general case. 11

Demonstrating Incorrectness Searching for counterexamples is the best way to disprove the correctness of a heuristic. Failure to find a counterexample to a given algorithm does not mean it is obvious that the algorithm is correct. Think about all small examples. Think about examples with ties on your decision criteria (e.g. pick the nearest point). Think about examples with extremes of big and small. Correctness is Not Obvious! Suppose you have a robot arm equipped with a tool, say a soldering iron. To enable the robot arm to do a soldering job we must construct an ordering of the contact points so the robot visits (and solders) the first contact point, then visits the second point, third, and so forth until the job is done. Since robots are expensive, we need to find the order which minimizes the time (i.e. travel distance) it takes to assemble the circuit board. 12

Correctness is Not Obvious! You are given the job to program the robot arm. Give an algorithm to find the shortest tour. Nearest Neighbor Tour A very popular solution starts at some point p 0 and then walks to its nearest neighbour p 1 first, then repeats from p 1, etc. until done. Pick and visit an initial point p 0 p = p 0 i = 0 While there are still unvisited points i = i + 1 Let p i be the closest unvisited point to p i-1 Visit p i Return to p 0 from p i 13

Nearest Neighbor Tour ddddddd A Correct Algorithm d = infinity For each of the n! permutations P(i) of the n points if (cost(p(i) <= d) then d = cost(p(i)) and Pmin = P(i) return Pmin Issue: 10! ~ 3 million TSP: NP Hard/Complete: verifiable: Polynomial time on deterministic TM solvable: Polynomial time by a nondeterministic TM 14

Why not use a supercomputer? Everyone knows Moore s Law a prediction made in 1965 by Intel co- founder Gordon Moore that the density of transistors in integrated circuits would continue to double every 1 to 2 years.in many areas, performance gains due to improvements in algorithms have vastly exceeded even the dramatic performance gains due to increased processor speed. Excerpt from Report to the President and Congress: Designing a Digital Future, December 2010 (page 71). https://www.whitehouse.gov/sites/default/files/microsites/os tp/pcast-nitrd-report-2010.pdf (No longer available) Why not use a supercomputer, cont. A faster algorithm running on a slower computer will always win for sufficiently large instances Usually, problems don t have to get that large before the faster algorithm wins 15

Expressing Algorithms What are the possible ways to express an algorithm? English Pseudocode Programming Language Two common types of algorithm design: Incremental: Iteratively run an algorithm (insert sort, next class) Analyze by counting iterations (as in CS 300) Recursive Divide and conquer (merge sort, following class) Analyze using recurrence equations (three methods to solve) Examples: Counting Iterations I DoubleLoop() int i, j for (i=1 to n) } for (j=1 to n) print i*j Square() for (i=1;i^2<=n;i++) print i } Time Complexity: Time Complexity: 16

Examples: Counting Iterations II TimesTwo() for (i=1;i<=n;i=2*i) print i } Time Complexity: Examples: Counting Iterations III 17

Examples: Counting Iterations IV TripleLoop() int i, j, k, n for (i = 1; i <= n; i++) for (j = 1; j <= i; j++) for (k = 1; k <= 100; k++) print i*j*k } } } } Time Complexity: Examples: Counting Iterations V AnotherDouble() int i, j, n for (i = 1; i <= n; i++) for (j = 1; j <= n; j = j+i) print i*j } } } Time Complexity: 18

For Next Time Read Chapters 1 and 2 from the book. 19