Chapter 1 - Mathematical Review Functions Factorial - x!=1*2*3*…..*x Permutation - a rearrangement of a sequence Boolean variable - takes on 2 values –

Slides:



Advertisements
Similar presentations
Lecture 2 Based on Chapter 1, Weiss. Mathematical Foundation Series and summation: ……. N = N(N+1)/2 (arithmetic series) 1 + r+ r 2 + r 3 +………r.
Advertisements

22C:19 Discrete Structures Induction and Recursion Fall 2014 Sukumar Ghosh.
Appendix B Solving Recurrence Equations : With Applications to Analysis of Recursive Algorithms.
Recursion, Divide and Conquer Lam Chi Kit (George) HKOI2007.
Recursion Ellen Walker CPSC 201 Data Structures Hiram College.
RECURSION Self referential functions are called recursive (i.e. functions calling themselves) Recursive functions are very useful for many mathematical.
Recursion COMP171 Fall Recursion / Slide 2 Recursion * In some problems, it may be natural to define the problem in terms of the problem itself.
Recursion. Binary search example postponed to end of lecture.
Proof Techniques and Recursion. Proof Techniques Proof by induction –Step 1: Prove the base case –Step 2: Inductive hypothesis, assume theorem is true.
Recursion. Objectives At the conclusion of this lesson, students should be able to Explain what recursion is Design and write functions that use recursion.
1 CSCD 300 Data Structures Recursion. 2 Proof by Induction Introduction only - topic will be covered in detail in CS 320 Prove: N   i = N ( N + 1.
1 Chapter 1: Introduction What you have learnt in Comp1220 or Comp1170? What will be taught in Comp 1200? - more Abstract Data Types -efficient algorithms.
1 Chapter 18 Recursion Dale/Weems/Headington. 2 Chapter 18 Topics l Meaning of Recursion l Base Case and General Case in Recursive Function Definitions.
Recursive Algorithms Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Recursion.
Discrete Maths Objective to show the close connection between recursive definitions and recursive functions , Semester 2, Recursion.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 19: Recursion.
1 CS 201 Data Structures & Algorithms Chapter 1 Introduction Text: Read Weiss, §1.1 – 1.3 Izmir University of Economics.
Direct proof technique
Chapter 2 - Mathematical Review Functions
1 CE 221 Data Structures & Algorithms Chapter 1 Introduction Text: Read Weiss, §1.1 – 1.3 Izmir University of Economics.
Advance Data Structure and Algorithm COSC600 Dr. Yanggon Kim Chapter 1.
CS 1704 Introduction to Data Structures and Software Engineering.
Chapter 1 Introduction. Goals Why the choice of algorithms is so critical when dealing with large inputs Basic mathematical background Review of Recursion.
Chapter 7 Recursion 1CSCI 3333 Data Structures. 2 Recurrent Sequence A recursively defined sequence – First, certain initial values are specified  c.f.,
Analyzing Complexity of Lists OperationSorted Array Sorted Linked List Unsorted Array Unsorted Linked List Search( L, x ) O(logn) O( n ) O( n ) Insert(
1 Chapter 13 Recursion. 2 Chapter 13 Topics l Meaning of Recursion l Base Case and General Case in Recursive Function Definitions l Writing Recursive.
1 Recursion. 2 Chapter 15 Topics  Meaning of Recursion  Base Case and General Case in Recursive Function Definitions  Writing Recursive Functions with.
CSC201 Analysis and Design of Algorithms Asst.Proof.Dr.Surasak Mungsing Oct-151 Lecture 2: Definition of algorithm and Mathematical.
Recursion Textbook chapter Recursive Function Call a recursive call is a function call in which the called function is the same as the one making.
Computer Science Department Data Structure & Algorithms Lecture 8 Recursion.
Methods of Proof Lecture 3: Sep 9. This Lecture Now we have learnt the basics in logic. We are going to apply the logical rules in proving mathematical.
1 Chapter 3. Recursion Lecture 6. In functions and data structures.
Recursion Recursion Chapter 12. Outline n What is recursion n Recursive algorithms with simple variables n Recursion and the run-time stack n Recursion.
1 CS 132 Spring 2008 Chapter 3 Pointers and Array-Based Lists read p
© M. Gross, ETH Zürich, 2014 Informatik I für D-MAVT (FS 2014) Exercise 12 – Data Structures – Trees Sorting Algorithms.
Edited by Malak Abdullah Jordan University of Science and Technology Data Structures Using C++ 2E Chapter 6 Recursion.
Basic Mathematics Chapter 1 (1.2 and 1.3) Weiss. Recursion / Slide 2 Logarithms * Definition: if and only if * Theorem 1.1: n Proof: apply the definition.
Math & Recursion COMP171 Fall Recursion / Slide 2 Logarithms * Definition: if and only if * Theorem 1.1: n Proof: apply the definition * Theorem.
Starting Out with C++ Early Objects Seventh Edition by Tony Gaddis, Judy Walters, and Godfrey Muganda Chapter 17: Linked Lists.
Cpt S 223 – Advanced Data Structures Math Review 2
Chapter 1: Introduction
1 Recursion n what is it? n how to build recursive algorithms n recursion analysis n tracing simple recursive functions n hands on attempts at writing.
1 Searching and Sorting Searching algorithms with simple arrays Sorting algorithms with simple arrays –Selection Sort –Insertion Sort –Bubble Sort –Quick.
1 Recursion. 2 Chapter 15 Topics  Meaning of Recursion  Base Case and General Case in Recursive Function Definitions  Writing Recursive Functions with.
Divide-and-Conquer UNC Chapel HillZ. Guo. Divide-and-Conquer It’s a technique instead of an algorithm Recursive in structure – Divide the problem into.
October 3, 2001CSE 373, Autumn Mathematical Background Exponents X A X B = X A+B X A / X B = X A-B (X A ) B = X AB X N +X N = 2X N 2 N +2 N = 2 N+1.
ADVANCED ALGORITHMS REVIEW OF ANALYSIS TECHNIQUES (UNIT-1)
Recursion. Problem decomposition Problem decomposition is a common technique for problem solving in programming – to reduce a large problem to smaller.
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 223 – Advanced Data Structures Math Review 1.
Programming With Java ICS201 University Of Ha’il1 Chapter 11 Recursion.
Divide and Conquer Faculty Name: Ruhi Fatima Topics Covered Divide and Conquer Matrix multiplication Recurrence.
Pei Zheng, Michigan State University 1 Chapter 8 Recursion.
CSS 342 DATA STRUCTURES, ALGORITHMS, AND DISCRETE MATHEMATICS I LECTURE CARRANO C++ INTERLUDE 2, CHAPT 4, 6.
1 Chapter 8 Recursion. 2 Recursive Function Call a recursion function is a function that either directly or indirectly makes a call to itself. but we.
Recursion. Objectives At the conclusion of this lesson, students should be able to Explain what recursion is Design and write functions that use recursion.
Methods of Proof Lecture 4: Sep 20 (chapter 3 of the book, except 3.5 and 3.8)
Section Recursion  Recursion – defining an object (or function, algorithm, etc.) in terms of itself.  Recursion can be used to define sequences.
Fall 2002CMSC Discrete Structures1 Chapter 3 Sequences Mathematical Induction Recursion Recursion.
Hubert Chan (Chapters 1.6, 1.7, 4.1)
MA/CSSE 473 Day 05 Factors and Primes Recursive division algorithm.
CS2210:0001Discrete Structures Induction and Recursion
Hubert Chan (Chapters 1.6, 1.7, 4.1)
Mathematical Induction Recursion
CSS 342 Data Structures, Algorithms, and Discrete Mathematics I
Applied Discrete Mathematics Week 9: Integer Properties
Chapter 18 Recursion.
Recursive Thinking.
11.4 Mathematical Induction
Recursion.
Presentation transcript:

Chapter 1 - Mathematical Review Functions Factorial - x!=1*2*3*…..*x Permutation - a rearrangement of a sequence Boolean variable - takes on 2 values – TRUE, FALSE – 0, 1 Floor - round down  x  Ceiling - round up  x  Modulus - mod - Remainder – x mod y - remainder when divide x by y – 10 mod 3 is 1

Logarithms log b y=x  b x =y  b log b y =y log mn = log m + log n – Let m=X A, n=X B, log(X A X B )=log(X A+B )=A+B=log m+ log b log m/n = log m - log n – X A /X B =X A-B log n r = r log n – (X A ) B =X AB log a n=log b n/log b a 2 n +2 n =2*2 n =2 n+1

Recursion A recursive algorithm calls itself. Must have a base case to stop recursion Calls must pass a “smaller problem” to the function. This will cause the recursion to eventually stop. Assume the recursive calls work. Factorial example: int fact(int n) { if (n<=1) return 1; else return n*fact(n-1) } Looks a bit like induction Better to use for’s and while’s when appropriate.

Non-Math Recursion Print out a linked list – A linked list is either An empty list (null pointer) or A head node followed by a linked list – Base case -> linked list is empty printLL(ptr) {if (ptr==NULL) return; else { cout data<<endl; printLL(ptr->next); }}

Summations

Proof Techniques Proof by Contradiction – Assume the opposite of the conclusion is true. Use steps to prove a contradiction (for example 1=2), then the original theorem must be true. Proof by induction – Show the theorem holds for a base case (n=0 or n=1) – Assume the theorem holds for n=k-1 – Prove the theorem is true for n=k – Example: show …+n=n(n+1)/2 for n=1 1=1(2)/2=1 assume …+n-1=(n-1)(n)/2; show 1+2+…+n=n(n+1)/2 (n-1)(n)/2+n=[(n-1)(n)+2n]/2=[n(n-1+2)]/2=n(n+1)/2

C++ Review Review the C++ material in Chapter 1 and ask necessary questions next time. I know there are several topics that you did not cover in 208, but you may be able to understand them with your current background. – If you don’t ask about them, I will assume you know how to use them and they will be fair game on the tests.

C++ topics Constructors – Default – Initializer list – Explicit – Copy constructor Preprocessor – #ifndef, etc. Pointers/Dynamic object creation Parameter Passing Return Passing Reference Variables Destructor, Operator = C arrays and strings Templates Stop at P. 32