Data Structure Lecture#4: Mathematical Preliminaries U Kang Seoul National University

Similar documents
Data Structure Lecture#4: Mathematical Preliminaries U Kang Seoul National University

Binomial Coefficient Identities/Complements

Mathematical Fundamentals

Recursion: Introduction and Correctness

CHAPTER 4 SOME METHODS OF PROOF

Algorithm Analysis Recurrence Relation. Chung-Ang University, Jaesung Lee

Part III, Sequences and Series CS131 Mathematics for Computer Scientists II Note 16 RECURRENCES

Math 324 Summer 2012 Elementary Number Theory Notes on Mathematical Induction

Algebra 1. Standard 1: Operations With Real Numbers Students simplify and compare expressions. They use rational exponents and simplify square roots.

IS 709/809: Computational Methods for IS Research. Math Review: Algorithm Analysis

CS173 Running Time and Big-O. Tandy Warnow

Cpt S 223. School of EECS, WSU

Lecture 6: Recurrent Algorithms:

Why do we need math in a data structures course?

5. Sequences & Recursion

1 Recursive Algorithms

Lecture 2. Fundamentals of the Analysis of Algorithm Efficiency

CSE 20. Final Review. CSE 20: Final Review

Chapter 5: Sequences, Mathematic Induction, and Recursion

4.1 Induction: An informal introduction

MATH 324 Summer 2011 Elementary Number Theory. Notes on Mathematical Induction. Recall the following axiom for the set of integers.

CS 2110: INDUCTION DISCUSSION TOPICS

California: Algebra 1

Administrivia. COMP9020 Lecture 7 Session 2, 2017 Induction and Recursion. Lecture 6 recap. Lecture 6 recap

Quiz 3 Reminder and Midterm Results

Algorithm efficiency analysis

CS173 Lecture B, September 10, 2015

Math 283 Spring 2013 Presentation Problems 4 Solutions

CS483 Design and Analysis of Algorithms

Integrated Math III. IM3.1.2 Use a graph to find the solution set of a pair of linear inequalities in two variables.

CmSc 250 Intro to Algorithms. Mathematical Review. 1. Basic Algebra. (a + b) 2 = a 2 + 2ab + b 2 (a - b) 2 = a 2-2ab + b 2 a 2 - b 2 = (a + b)(a - b)

Fall 2017 Test II review problems

Matrix Multiplication

Recursion and Induction

Section 4.1: Sequences and Series

SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION

CS Analysis of Recursive Algorithms and Brute Force

CMSC250 Homework 9 Due: Wednesday, December 3, Question: Total Points: Score:

ITEC2620 Introduction to Data Structures

Chapter 8: Recursion. March 10, 2008

Problem Set 5 Solutions

General Comments on Proofs by Mathematical Induction

CSE 311: Foundations of Computing. Lecture 14: Induction

Great Theoretical Ideas in Computer Science

cse547, math547 DISCRETE MATHEMATICS Professor Anita Wasilewska

Solving recurrences. Frequently showing up when analysing divide&conquer algorithms or, more generally, recursive algorithms.

n n P} is a bounded subset Proof. Let A be a nonempty subset of Z, bounded above. Define the set

Online Courses for High School Students

Homework #2 Solutions Due: September 5, for all n N n 3 = n2 (n + 1) 2 4

UCSD CSE 21, Spring 2014 [Section B00] Mathematics for Algorithm and System Analysis

Recurrences COMP 215

CS Non-recursive and Recursive Algorithm Analysis

CSC 125 :: Final Exam May 3 & 5, 2010

Mathematical Induction

Propositional Logic, Predicates, and Equivalence

Learning Objectives

What we have learned What is algorithm Why study algorithm The time and space efficiency of algorithm The analysis framework of time efficiency Asympt

MAT 300 RECITATIONS WEEK 7 SOLUTIONS. Exercise #1. Use induction to prove that for every natural number n 4, n! > 2 n. 4! = 24 > 16 = 2 4 = 2 n

Another Proof By Contradiction: 2 is Irrational

COMP 555 Bioalgorithms. Fall Lecture 3: Algorithms and Complexity

CS483 Design and Analysis of Algorithms

1.1 Inductive Reasoning filled in.notebook August 20, 2015

CS Algorithms and Complexity

Analysis of Algorithms I: Asymptotic Notation, Induction, and MergeSort

1 Examples of Weak Induction

1 Direct Proofs Technique Outlines Example Implication Proofs Technique Outlines Examples...

3.1 Induction: An informal introduction

Lecture 12 : Recurrences DRAFT

Mathematical Induction

Correlation: California State Curriculum Standards of Mathematics for Grade 6 SUCCESS IN MATH: BASIC ALGEBRA

Correlation of Moving with Math Grade 7 to HSEE Mathematics Blueprint

Discrete Mathematics and Probability Theory Fall 2013 Vazirani Note 1

Writing Mathematical Proofs

Input Decidable Language -- Program Halts on all Input Encoding of Input -- Natural Numbers Encoded in Binary or Decimal, Not Unary

Computer Algorithms CISC4080 CIS, Fordham Univ. Outline. Last class. Instructor: X. Zhang Lecture 2

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

Analysis of Algorithms - Using Asymptotic Bounds -

General Comments Proofs by Mathematical Induction

The Process of Mathematical Proof

Math 3000 Section 003 Intro to Abstract Math Homework 6

CS 4104 Data and Algorithm Analysis. CS4014: What You Need to Already Know. CS4104: What We Will Do. Introduction to Problem Solving (1)

Week 7 Solution. The two implementations are 1. Approach 1. int fib(int n) { if (n <= 1) return n; return fib(n 1) + fib(n 2); } 2.

An Introduction to Proofs in Mathematics

Chapter 2 Section 2.1: Proofs Proof Techniques. CS 130 Discrete Structures

CS1800: Mathematical Induction. Professor Kevin Gold

Module 9: Mathematical Induction

Climbing an Infinite Ladder

1 True/False. Math 10B with Professor Stankova Worksheet, Discussion #9; Thursday, 2/15/2018 GSI name: Roy Zhao

Discrete Mathematics. Spring 2017

CS383, Algorithms Spring 2009 HW1 Solutions

Fall Lecture 5

1 Sequences and Summation

MI 4 Mathematical Induction Name. Mathematical Induction

Discrete Mathematics U. Waterloo ECE 103, Spring 2010 Ashwin Nayak May 17, 2010 Recursion

Algoritmi di Bioinformatica. Computational efficiency I

CSE373: Data Structures and Algorithms Lecture 3: Math Review; Algorithm Analysis. Catie Baker Spring 2015

Analysis of Algorithms

Solutions to Tutorial 4 (Week 5)

CSC2100B Data Structures Analysis

CSC236 Week 2. Larry Zhang

Transcription:

Data Structure Lecture#4: Mathematical Preliminaries U Kang Seoul National University U Kang 1

In This Lecture Set Concepts and Notation Relation Logarithm and Summations Recurrence Relations Recursion Induction Proofs U Kang 2

Recurrence Relation Recurrence relation defines a function by an expression that includes itself Factorial: n! = (n-1)! * n for n >1; 1! = 0! = 1 Fibonacci sequence Fib(n) = Fib(n-1) + Fib(n-2) for n > 2; Fib(1) = Fib(2) = 1 Closed form solution: solution without recurrence E.g., Factorial n! = n * (n-1) * * 1 How to get a closed form solution? Expansion. U Kang 3

Closed Form for Recurrence T(n) = T(n-1) + 1 for n > 1; T(0) = T(1) = 0 Closed form solution: T(n) =? T(n) = T(n-1) + n; T(1) = 1 Closed form solution: T(n) =? U Kang 4

Recursion An algorithm is recursive if it calls itself to do part of its work. Example: 1. Compute n! 2. Hanoi puzzle U Kang 5

Recursion: n! When solving recursion, don t worry about how the recursive call solves the subproblem. Simply accept that it will solve it correctly. U Kang 6

Tower of Hanoi Problem: move the rings in the leftmost pole to the rightmost pole A ring can never be moved on top of a smaller ring Key to solution: use recursive function U Kang 7

Tower of Hanoi Assume that a function X can move top n-1 rings to pole 2 (Fig (b)) U Kang 8

Mathematical Proof Three templates for mathematical proof 1. Deduction 2. Proof by contradiction 3. Proof by mathematical induction U Kang 9

Proof Technique 1 - Deduction Deduction Argument in terms of logic If we want to prove P => R, then we may prove P => Q, then Q=>R If we want to prove that P and Q are equivalent, then we can first prove P => Q, and then Q=> P U Kang 10

Proof Technique 2 - Contradiction The simplest way to disprove a theorem: use counterexample! E.g., everyone in the earth is female But, no number of examples supporting a theorem is sufficient to prove it Proof by contradiction (e.g., P => Q) Assume the theorem is false (Q is false) Then a logical contradiction stems from it Thus we can conclude that the theorem is true U Kang 11

Proof Technique 2 - Contradiction Example Theorem: No integer is the largest. Proof Assume x is the largest integer y = x+1 is an integer, since it is the sum of two integers (x and 1) But then, y is the largest integer which contradicts the assumption U Kang 12

Proof Technique 3 Mathematical induction We want to prove that theorem X is true for all integers n c Base case: prove that X holds for n = c Induction step: If X holds for n-1, then X holds for n This is called Induction Hypothesis An alternative induction step: If X holds for all c i n-1, then X holds for n U Kang 13

Proof Technique 3 Mathematical induction E.g., Thrm: S(n) = 1+2+ +n = n(n+1)/2 for n 1 Base case: 1 = 1*(1+1)/2 Induction Hypothesis (I.H.): S(n-1) = (n-1)n/2 Use I.H. to show that Thrm is true for S(n) S(n) = S(n-1) + n = (n-1)n/2 + n = n(n+1)/2 U Kang 14

Proof Technique 3 Mathematical induction E.g., Thrm: function fact(n) will terminate for any n 1 Base case: fact(1) terminates (returns 1) I.H. : fact(n-1) terminates Use I.H. to show that Thrm is true for n fact(n) multiplies n with fact(n-1), and thus it will terminate as well U Kang 15

Estimation Techniques Known as back of the envelope or back of the napkin calculation 1. Determine the major parameters that effect the problem. 2. Find an equation that relates the parameters to the problem. 3. Select values for the parameters, and apply the equation to yield estimated solution. U Kang 16

Why Estimation Techniques? Need to make quick estimates To check feasibility For decision making Principles Small error is fine Make order of magnitude estimate. Round to nearest order of magnitude Make a reasonable guess on numbers you do not know Interpolate / Extraplote from what you know Upper and lower bounds of the estimates can be helpful Making good back of envelope calculation (in your brain) is a crucial strength of CS students. Develop it! U Kang 17

Estimation Example How many library bookcases does it take to store books totaling one million pages? Estimate: A 500-pages book requires ~ 2.5 cm => 1 million pages require ~ 5000 cm = 50 m of shelf space => A shelf is ~ 1 m wide, thus ~ 50 shelves are needed => A bookcase contains 5 shelves, thus 10 library bookcases needed U Kang 18

Estimation Example How many hair designers are needed in Seoul? U Kang 19

What You Need to Know Recurrence Express problems using recurrence relations Find closed form solution for recurrence Write functions with recursion Mathematical proof Deduction, by contradiction, by mathematical induction Prove using contradiction Prove using mathematical induction Be familiar with estimation techniques U Kang 20

Questions? U Kang 21