Tutorial 2 - Daniel Razavi

Slides:



Advertisements
Similar presentations
PROOF BY CONTRADICTION
Advertisements

The Fundamental Theorem of Arithmetic (2/12) Definition (which we all already know). A number greater than 1 is called prime if its only divisors are 1.
Induction and recursion
CPSC 668Set 7: Mutual Exclusion with Read/Write Variables1 CPSC 668 Distributed Algorithms and Systems Fall 2009 Prof. Jennifer Welch.
Tirgul 10 Rehearsal about Universal Hashing Solving two problems from theoretical exercises: –T2 q. 1 –T3 q. 2.
Data Structures – LECTURE 10 Huffman coding
Tirgul 6 B-Trees – Another kind of balanced trees Problem set 1 - some solutions.
1 Recitation 10. Induction Introduction. Induction is useful in proving properties of recursive algorithms, like their execution times. It is also the.
Strong Induction, WOP and Invariant Method Leo Cheung.
4.8 Huffman Codes These lecture slides are supplied by Mathijs de Weerd.
4. There once lived a king, named Hagar, who had thousands of sons and daughters, still giving more births to his wives. One of his serious problems was.
1 Section 3.3 Mathematical Induction. 2 Technique used extensively to prove results about large variety of discrete objects Can only be used to prove.
A quadratic equation is a second degree polynomial, usually written in general form: The a, b, and c terms are called the coefficients of the equation,
Induction and recursion
Section 5.3. Section Summary Recursively Defined Functions Recursively Defined Sets and Structures Structural Induction.
4.8 Huffman Codes These lecture slides are supplied by Mathijs de Weerd.
Discrete Mathematics Tutorial 11 Chin
Binary Trees. Binary Tree Finite (possibly empty) collection of elements A nonempty binary tree has a root element The remaining elements (if any) are.
Discrete Structures Lecture 12: Trees Ji Yanyan United International College Thanks to Professor Michael Hvidsten.
Prof. Busch - LSU1 Mathematical Preliminaries. Prof. Busch - LSU2 Mathematical Preliminaries Sets Functions Relations Graphs Proof Techniques.
Reading and Writing Mathematical Proofs Spring 2015 Lecture 4: Beyond Basic Induction.
Proofs, Induction and Recursion Basic Proof Techniques Mathematical Induction Recursive Functions and Recurrence Relations.
Copyright © Zeph Grunschlag, Induction Zeph Grunschlag.
5.5.2 M inimum spanning trees  Definition 24: A minimum spanning tree in a connected weighted graph is a spanning tree that has the smallest possible.
ICS 253: Discrete Structures I Induction and Recursion King Fahd University of Petroleum & Minerals Information & Computer Science Department.
+ David Kauchak cs312 Review. + Midterm Will be posted online this afternoon You will have 2 hours to take it watch your time! if you get stuck on a problem,
CS 103 Discrete Structures Lecture 13 Induction and Recursion (1)
CMSC 341 Introduction to Trees. 2/21/20062 Tree ADT Tree definition –A tree is a set of nodes which may be empty –If not empty, then there is a distinguished.
Mathematical Induction Section 5.1. Climbing an Infinite Ladder Suppose we have an infinite ladder: 1.We can reach the first rung of the ladder. 2.If.
1 Mathematical Preliminaries. 2 Sets Functions Relations Graphs Proof Techniques.
Copyright © Zeph Grunschlag, Induction Zeph Grunschlag.
Copyright © Cengage Learning. All rights reserved. Sequences and Series.
CompSci 102 Discrete Math for Computer Science March 13, 2012 Prof. Rodger Slides modified from Rosen.
Chapter 5. Section 5.1 Climbing an Infinite Ladder Suppose we have an infinite ladder: 1.We can reach the first rung of the ladder. 2.If we can reach.
EXAMPLE 3 Write an indirect proof Write an indirect proof that an odd number is not divisible by 4. GIVEN : x is an odd number. PROVE : x is not divisible.
Chapter 11. Chapter Summary  Introduction to trees (11.1)  Application of trees (11.2)  Tree traversal (11.3)  Spanning trees (11.4)
CSC317 1 Binary Search Trees (binary because branches either to left or to right) Operations: search min max predecessor successor. Costs? Time O(h) with.
Chapter 5 With Question/Answer Animations 1. Chapter Summary Mathematical Induction - Sec 5.1 Strong Induction and Well-Ordering - Sec 5.2 Lecture 18.
Mathematical Induction What it is? Why is it a legitimate proof method? How to use it?
Trees.
Chapter 5 1. Chapter Summary  Mathematical Induction  Strong Induction  Recursive Definitions  Structural Induction  Recursive Algorithms.
Lecture 2: Proofs and Recursion. Lecture 2-1: Proof Techniques Proof methods : –Inductive reasoning Lecture 2-2 –Deductive reasoning Using counterexample.
DAST Tirgul 7.
Propositional Logic.
CSCE 668 DISTRIBUTED ALGORITHMS AND SYSTEMS
4.8 Huffman Codes These lecture slides are supplied by Mathijs de Weerd.
Recursive Objects (Part 4)
Induction and recursion
Summary of General Binary search tree
CMSC 341 Introduction to Trees.
ITEC 2620M Introduction to Data Structures
Discrete Structures for Computer Science
Advanced Algorithms Analysis and Design
Slide Sources: CLRS “Intro. To Algorithms” book website
(edited by Nadia Al-Ghreimil)
Context Free Pumping Lemma Some languages are not context free!
Taibah University College of Computer Science & Engineering Course Title: Discrete Mathematics Code: CS 103 Chapter 10 Trees Slides are adopted from “Discrete.
Slide Sources: CLRS “Intro. To Algorithms” book website
Induction and recursion
CSCE 668 DISTRIBUTED ALGORITHMS AND SYSTEMS
4.8 Huffman Codes These lecture slides are supplied by Mathijs de Weerd.
Propositional Logic.
Binary SearchTrees [CLRS] – Chap 12.
Mathematical Induction
Heaps By JJ Shepherd.
Depth of an AVL tree Theorem: Any AVL tree with n nodes has height less than log n. Proof: Given an n-node AVL tree, we want to find an upper bound.
Tutorial Number 8 - Daniel Razavi
Mathematical Induction II
From the last time: gcd(a, b) can be characterized in two different ways: It is the least positive value of ax + by where x and y range over integers.
Presentation transcript:

Tutorial 2 - Daniel Razavi CSC 236 Tutorial 2 - Daniel Razavi

Apologies Regarding The Slides

New Website

danielrazavi.github.io

Questions about the Problem Set?

Today’s Problem Set

Don’t worry about the bonus yet

Step 1: Base Case

Step 1: Base Case We know that the smallest number n can be is 1. So we are gonna choose that for our base case. n = 1 can be written as 2^0 Base Case Proved!

Step 2: Inductive Case

2x + 2y + ... = m Step 2: Inductive Case Suppose that n >= 1 and that 1 <= m <= n can be written as the sum of powers of 2. Some x, y, m 2x + 2y + ... = m Our Assumption

2x + 2y + ... = m Step 2: Inductive Case Suppose that n >= 1 and that 1 <= m <= n can be written as the sum of powers of 2. Some x, y, m 2x + 2y + ... = m Our Assumption Now all we have to do is to prove that m+1 can be written as a sum of powers of 2.

Step 2: Inductive Case As m+1 >= 2, it is true that there is some k >= 0 such that 1 <= 2k <= m+1. And pretty much when it comes to this example, there are two cases when you simplify this: If m+1 = 2k If m+1 = 2k + p

Step 2: Inductive Case As m+1 >= 2, it is true that there is some k >= 0 such that 1 <= 2k <= m+1. And pretty much when it comes to this example, there are two cases when you simplify this: If m+1 = 2k If m+1 = 2k + p Then we are DONE!! Since m+1 can be written as a sum of powers of 2.

Step 2: Inductive Case p is some number that As m+1 >= 2, it is true that there is some k >= 0 such that 1 <= 2k <= m+1. And pretty much when it comes to this example, there are two cases when you simplify this: If m+1 = 2k If m+1 = 2k + p p is some number that 1<= p <= n. Then we are DONE!! Since m+1 can be written as a sum of powers of 2.

Step 2: Inductive Case p is some number that As m+1 >= 2, it is true that there is some k >= 0 such that 1 <= 2k <= m+1. And pretty much when it comes to this example, there are two cases when you simplify this: If m+1 = 2k If m+1 = 2k + p p is some number that 1<= p <= n. Then we are DONE!! Since m+1 can be written as a sum of powers of 2. p cannot be n+1 or larger since then we will end up with m+1 = 2k + n +1. This doesn't make any sense since the smallest number that 2k can be is 1, and either m=n or m<n, making the right side to be always larger than left side if p is n+1 or larger.

Step 2: Inductive Case p is some number that 1<= p <= n. As m+1 >= 2, it is true that there is some k >= 0 such that 1 <= 2k <= m+1. And pretty much when it comes to this example, there are two cases when you simplify this: If m+1 = 2k If m+1 = 2k + p And by our Inductive Hypothesis, we know that p can be written as the sum of powers of 2. So both p and 2k can be written as the sum of powers of 2, that means m+1 can be written as a sum of powers of 2 also. Then we are DONE!! Since m+1 can be written as a sum of powers of 2.

PROVED Step 2: Inductive Case p is some number that 1<= p <= n. As n+1 >= 2, it is true that there is some k >= 0 such that 1 <= 2k <= n+1. And pretty much when it comes to this example, there are two cases when you simplify this: If m+1 = 2k If m+1 = 2k + p And by our Inductive Hypothesis, we know that p can be written as the sum of powers of 2. So both p and 2k can be written as the sum of powers of 2, that means m+1 can be written as a sum of powers of 2 also. Then we are DONE!! Since m+1 can be written as a sum of powers of 2.

Bonus can be a Home Exercise.

Good for you for checking this out at home:) Profs Solution for the Bonus For the bonus: this is low-priority material for the tutorial, but if there's time: We begin with this lemma: \sum_{i=0}^{n-1} 2^i < 2^n. This can be proved using simple induction, or using the formula for a geometric series: \sum_{i=0}^{n-1} 2^i = (1-2^n)/(1-2) = 2^n-1 < 2^n Now suppose for contradiction that there are two distinct binary representations b1 and b2 for n >= 1. Moving from highest-power to lowest-power, at some point b1 and b2 must differ in a bit. Suppose that b1 at that first differing position, q, = 1 and b2 in that position = 0. Ignore all bits to the left to produce b1' and b2'. Consider what remains in both b1' and b2'. b1' >= 2^q (because bit q is a 1 in b1') b2' < 2^q (by lemma) Contradiction: this implies that n is greater than and less than the same value.

Step 1: Base Case

Step 1: Base Case The height of the tree is 1, and when the height is 1, there is only one leaf note. Which means the entire tree has an odd number of nodes (well in this case node). Proved.

Step 2: Inductive Case Suppose that any full binary tree of height 1, 2, ..., h, has an odd number of nodes. Our Assumption

Step 2: Inductive Case Suppose that any full binary tree of height 1, 2, ..., h, has an odd number of nodes. Our Assumption Now all we have to do is to prove that a full binary tree of height h+1 also has odd number of nodes.

Step 2: Inductive Case Now we know that at any full binary tree, the root node is supposed to have 2 children. But let's look at it differently. Let's say that the root parent has two other trees as its children.

Step 2: Inductive Case Now we know that at any full binary tree, the root node is supposed to have 2 children. But let's look at it differently. Let's say that the root parent has two other trees as its children. We know that the subtrees are full binary trees, so that means that they have odd number of nodes. (odd) + (odd) + 1 = (even) + 1 = (odd) Tree 1 (Full Binary Sub-Tree) Tree 2 (Full Binary Sub-Tree

PROVED Step 2: Inductive Case Now we know that at any full binary tree, the root node is supposed to have 2 children. But let's look at it differently. Let's say that the root parent has two other trees as its children. We know that the subtrees are full binary trees, so that means that they have odd number of nodes. (odd) + (odd) + 1 = (even) + 1 = (odd) Tree 1 (Full Binary Sub-Tree) Tree 2 (Full Binary Sub-Tree

Tree 1 (Full Binary Sub-Tree) The proof is very similar by structural induction. We have a recursive definition for T, the set of nonempty binary trees: Any single node is in T If t1 and t2 in T, then a new tree with root r and subtrees t1 and t2 is in T. Tree 1 (Full Binary Sub-Tree) Tree 2 (Full Binary Sub-Tree Really Similar to the Example in the Readings (Notes.pdf) on Page 19

Base Case: a propositional variable P. If P has 0 occurrences of true variables, then P is false as required. Otherwise, P has an odd number of true variables (1), and P is true as required.

Inductive case: suppose that s1 and s2 are two well-formed xor formulas. Then, using the IH twice: s1 is true iff an odd number of its variables is set to true. s2 is true iff an odd number of its variables is set to true.

Inductive case: suppose that s1 and s2 are two well-formed xor formulas. Then, using the IH twice: s1 is true iff an odd number of its variables is set to true. s2 is true iff an odd number of its variables is set to true. We must prove that: (s1 xor s2) is true if and only if an odd number of its variables is set to true.

If you remember from MAT102: This question brings up two conditions with it. If (s1 xor s2) is true, then an odd number of its variables is set to true. We must prove that: (s1 xor s2) is true if and only if an odd number of its variables is set to true. If an odd number of variables is true, then (s1 xor s2) is true.

If (s1 xor s2) is true, then an odd number of its variables is set to true. For (s1 xor s2) to be true, exactly one of s1 or s2 is true and the other is false. Then, by the IH, one of s1 and s2 has an odd number of true variables and the other has an even number of true variables. So, (s1 xor s2) has (odd + even) = odd number of true variables. We must prove that: (s1 xor s2) is true if and only if an odd number of its variables is set to true.

If an odd number of variables is true, then (s1 xor s2) is true. There are an odd number of true variables, so one of s1 and s2 must have an odd number of true variables and the other must have an even number of true variables. Two odds add up to an even, and two evens add up to an even, so those can't happen. But then, by the IH, one of s1 and s2 is true and the other is false. By the definition of xor, (s1 xor s2) is true. We must prove that: (s1 xor s2) is true if and only if an odd number of its variables is set to true.

If an odd number of variables is true, then (s1 xor s2) is true. There are an odd number of true variables, so one of s1 and s2 must have an odd number of true variables and the other must have an even number of true variables. Two odds add up to an even, and two evens add up to an even, so those can't happen. But then, by the IH, one of s1 and s2 is true and the other is false. By the definition of xor, (s1 xor s2) is true. We must prove that: (s1 xor s2) is true if and only if an odd number of its variables is set to true. We mention this due to the whole “uniqueness” thing

Tutorial 2 - Daniel Razavi CSC 236 Tutorial 2 - Daniel Razavi