csci 2200 foundations of computer science
play

CSCI-2200 FOUNDATIONS OF COMPUTER SCIENCE Spring 2017 March 21, - PowerPoint PPT Presentation

1 CSCI-2200 FOUNDATIONS OF COMPUTER SCIENCE Spring 2017 March 21, 2017 2 Logistics Prof. Stacy Patterson sep@cs.rpi.edu, pattes3@rpi.edu Office hours: Monday 2pm 3:30pm (or by appointment) in Lally 301 Homework 5 is due


  1. 1 CSCI-2200 FOUNDATIONS OF COMPUTER SCIENCE Spring 2017 March 21, 2017

  2. 2 Logistics • Prof. Stacy Patterson sep@cs.rpi.edu, pattes3@rpi.edu • Office hours: Monday 2pm – 3:30pm (or by appointment) in Lally 301 • Homework 5 is due Friday, March 24 at 11:59pm. • Today: • Review of induction and strong induction (5.1-5.2) • Recursive Definitions and Structural Induction (5.3) • Trees

  3. 3 Principle of Mathematical Induction • To prove that P ( n ) is true for all positive integers ≥ b , we complete these steps: • Basis Step : Show that P ( b ) is true • Inductive Step : Show that P ( k ) → P ( k + 1 ) is true for all positive integers k ≥ b • P(k) is the inductive hypothesis .

  4. 4 Prove that a set with n elements has n(n-1)/2 subsets with exactly 2 elements.

  5. 5

  6. 6 Why Induction Works? P (1) ∀ k ( P ( k ) → P ( k + 1)) ∀ nP ( n ) ∴ • This is a valid argument.

  7. 7

  8. 8 Graphs • A graph G=(V,E) is a set of vertices V and a set of edges E. • We study “undirected graphs”. • A path between vertices i and j is a sequence of edges that connect i and j • A connected graph is a graph in which there is a path between every pair of vertices.

  9. 9 Trees • A tree is connected graph with no cycles. • Only a single path between any pair of vertices • A rooted tree is a special type of graph. It contains a distinguished vertex called the root .

  10. 10 Recursive Definition of a Rooted Tree • Recursive definition of a rooted tree: • Basis step: A single vertex r is a rooted tree. • Recursive step: Suppose that T 1 , T 2 , …, T m are disjoint rooted trees. Then the graph formed by starting with a root r, which is not in any of T 1 , … , T m , and adding an edge from the root of each T i to r is a rooted tree.

  11. 11 Recursive Definition of a Full Binary Tree • A full binary tree is a rooted tree in which each vertex has either 0 or 2 children. • Recursive definition : • Basis step: A single vertex r is a full binary tree • Recursive step : If T 1 and T 2 are full disjoint full binary trees, there is a full binary tree, denoted T 1 Ÿ T 2, consisting of a root r with edges connecting to the roots of T 1 and T 2 .

  12. 12 Number of nodes in a Full Binary Tree • Recursive definition of FBT: • Basis step: A single vertex r is a full binary tree. • Recursive step : If T 1 and T 2 are disjoint full binary trees, there is a full binary tree, denoted T 1 Ÿ T 2, consisting of a root r with edges connecting to the roots of T 1 and T 2 . • Recursive definition of number of vertices in a FBT:

  13. 13 Height of a Full Binary Tree • Recursive definition of FBT: • Basis step: A single vertex r is a full binary tree • Recursive step : If T 1 and T 2 are full disjoint full binary trees, there is a full binary tree, denoted T 1 Ÿ T 2, consisting of a root r with edges connecting to the roots of T 1 and T 2 . • Theorem : If T is a full binary tree, then N(T) ≥ 2H(T) + 1

  14. 14 Structural Induction • We can use structural induction to prove results about recursively defined sets and structures. • A proof by structural induction has two parts: • Basis Step: Show the result holds for the structure(s) specified in the basis step of the recursive definition. • Recursive Step: Show that if the statement is true for each structure used to construct the new structure, then it is true for the new structure.

  15. 15 • Theorem : If T is a full binary tree, then N(T) ≥ 2H(T) + 1

  16. 16 • Theorem : If T is a full binary tree, then N(T) ≥ 2H(T) + 1

  17. 17 Good Problems to Review • Section 5.2: 3, 5, 7, 13, 25, 29 • Section 5.3: 23, 25

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend