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

csci 2200 foundations of computer science
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

CSCI-2200 FOUNDATIONS OF COMPUTER SCIENCE

Spring 2017

March 21, 2017

1

slide-2
SLIDE 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

2

slide-3
SLIDE 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.

3

slide-4
SLIDE 4

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

4

slide-5
SLIDE 5

5

slide-6
SLIDE 6

Why Induction Works?

  • This is a valid argument.

6

P(1) ∀k(P(k) → P(k + 1)) ∴ ∀nP(n)

slide-7
SLIDE 7

7

slide-8
SLIDE 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.

8

slide-9
SLIDE 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.

9

slide-10
SLIDE 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 T1, T2, …, Tm are disjoint rooted trees. Then

the graph formed by starting with a root r, which is not in any of T1, … , Tm, and adding an edge from the root of each Ti to r is a rooted tree.

10

slide-11
SLIDE 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 T1 and T2 are full disjoint full binary trees, there is a full

binary tree, denoted T1ŸT2, consisting of a root r with edges connecting to the roots of T1 and T2.

11

slide-12
SLIDE 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 T1 and T2 are disjoint full binary trees, there is a

full binary tree, denoted T1ŸT2, consisting of a root r with edges connecting to the roots of T1 and T2.

  • Recursive definition of number of vertices in a FBT:

12

slide-13
SLIDE 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 T1 and T2 are full disjoint full binary trees, there is a full

binary tree, denoted T1ŸT2, consisting of a root r with edges connecting to the roots of T1 and T2.

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

13

slide-14
SLIDE 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.

14

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

15

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

16

slide-17
SLIDE 17

Good Problems to Review

  • Section 5.2: 3, 5, 7, 13, 25, 29
  • Section 5.3: 23, 25

17