TA: Jade Cheng ICS 241 Recitation Lecture Notes #12 November 13, 2009

Similar documents
3. According to universal addressing, what is the address of vertex d? 4. According to universal addressing, what is the address of vertex f?

CSC Discrete Math I, Spring Sets

[Ch 6] Set Theory. 1. Basic Concepts and Definitions. 400 lecture note #4. 1) Basics

2.2 Set Operations. Introduction DEFINITION 1. EXAMPLE 1 The union of the sets {1, 3, 5} and {1, 2, 3} is the set {1, 2, 3, 5}; that is, EXAMPLE 2

CS February 17

TA: Jade Cheng ICS 241 Recitation Lecture Note #9 October 23, 2009

Propositional Calculus: Boolean Algebra and Simplification. CS 270: Mathematical Foundations of Computer Science Jeremy Johnson

Math 15 - Spring Homework 5.2 Solutions

24 Nov Boolean Operations. Boolean Algebra. Boolean Functions and Expressions. Boolean Functions and Expressions

c) the set of students at your school who either are sophomores or are taking discrete mathematics

Propositional Calculus. CS 270: Mathematical Foundations of Computer Science Jeremy Johnson

Permutation Matrices. Permutation Matrices. Permutation Matrices. Permutation Matrices. Isomorphisms of Graphs. 19 Nov 2015

DO NOT RE-DISTRIBUTE THIS SOLUTION FILE

COMP combinational logic 1 Jan. 18, 2016

Dijkstra s algorithm for shortest paths when no edges have negative weight.

LECTURE 2 An Introduction to Boolean Algebra

To prove something about all Boolean expressions, we will need the following induction principle: Axiom 7.1 (Induction over Boolean expressions):

Chapter 9 Graph Algorithms

Introduction to Boolean logic and Logical Gates

Information Science 1

11/22/2016. Chapter 9 Graph Algorithms. Introduction. Definitions. Definitions. Definitions. Definitions

To prove something about all Boolean expressions, we will need the following induction principle: Axiom 7.1 (Induction over Boolean expressions):

Definitions. 03 Logic networks Boolean algebra. Boolean set: B 0,

4/8/11. Single-Source Shortest Path. Shortest Paths. Shortest Paths. Chapter 24

CSE 215: Foundations of Computer Science Recitation Exercises Set #9 Stony Brook University. Name: ID#: Section #: Score: / 4

CSE331 Introduction to Algorithms Lecture 15 Minimum Spanning Trees

Trees Rooted Trees Spanning trees and Shortest Paths. 12. Graphs and Trees 2. Aaron Tan November 2017

Sets. Mukulika Ghosh. Fall Based on slides by Dr. Hyunyoung Lee

SYNERGY INSTITUTE OF ENGINEERING & TECHNOLOGY,DHENKANAL LECTURE NOTES ON DIGITAL ELECTRONICS CIRCUIT(SUBJECT CODE:PCEC4202)

Boolean Functions (10.1) Representing Boolean Functions (10.2) Logic Gates (10.3)

Algorithm Analysis Graph algorithm. Chung-Ang University, Jaesung Lee

Homework 5: Graphs, Minimum Spanning Trees, and Dijkstra Shortest-Path

Definition For vertices u, v V (G), the distance from u to v, denoted d(u, v), in G is the length of a shortest u, v-path. 1

Introduction to Boolean Algebra

Exam 3 Practice Problems

Introduction to Boolean Algebra

Taibah University College of Computer Science & Engineering Course Title: Discrete Mathematics Code: CS 103. Chapter 2. Sets

LECTURE 26 PRIM S ALGORITHM

22 Elementary Graph Algorithms. There are two standard ways to represent a

We ve done. Introduction to the greedy method Activity selection problem How to prove that a greedy algorithm works Fractional Knapsack Huffman coding

CONTENTS Equivalence Classes Partition Intersection of Equivalence Relations Example Example Isomorphis

Chapter 23. Minimum Spanning Trees

Notation Index. Probability notation. (there exists) (such that) Fn-4 B n (Bell numbers) CL-27 s t (equivalence relation) GT-5.

Propositional Calculus

1 Minimum Spanning Trees (MST) b 2 3 a. 10 e h. j m

CPS 102: Discrete Mathematics. Quiz 3 Date: Wednesday November 30, Instructor: Bruce Maggs NAME: Prob # Score. Total 60

9/19/12. Why Study Discrete Math? What is discrete? Sets (Rosen, Chapter 2) can be described by discrete math TOPICS

Minimum spanning trees

We have already seen the transportation problem and the assignment problem. Let us take the transportation problem, first.

Chapter 9 Graph Algorithms

18 Spanning Tree Algorithms

Mathematical Logic Prof. Arindama Singh Department of Mathematics Indian Institute of Technology, Madras. Lecture - 9 Normal Forms

CSE 100: B+ TREE, 2-3 TREE, NP- COMPLETNESS

(d) If the moon shares nothing and the sun does not share our works, then the earth is alive with creeping men.

Logic Synthesis & Optimization Lectures 4, 5 Boolean Algebra - Basics

Lecture 13. Reading: Weiss, Ch. 9, Ch 8 CSE 100, UCSD: LEC 13. Page 1 of 29

Recitation 13. Minimum Spanning Trees Announcements. SegmentLab has been released, and is due Friday, November 17. It s worth 135 points.

r=1 The Binomial Theorem. 4 MA095/98G Revision

Propositional Calculus. Math Foundations of Computer Science

CSE 21 Mathematics for Algorithm and System Analysis

CS264: Homework #4. Due by midnight on Wednesday, October 22, 2014

CIS 121 Data Structures and Algorithms Minimum Spanning Trees

MEI Conference 2009: D2

Name: Lirong TAN 1. (15 pts) (a) Define what is a shortest s-t path in a weighted, connected graph G.

WUCT121. Discrete Mathematics. Graphs

STUDENT NUMBER: MATH Final Exam. Lakehead University. April 13, Dr. Adam Van Tuyl

Minimal Spanning Trees

UNIT 3. Greedy Method. Design and Analysis of Algorithms GENERAL METHOD

Introduction to Graph Theory

BOOLEAN ALGEBRA AND CIRCUITS

Decreasing a key FIB-HEAP-DECREASE-KEY(,, ) 3.. NIL. 2. error new key is greater than current key 6. CASCADING-CUT(, )

Kruskal s MST Algorithm

Logic Design: Part 2

2. CONNECTIVITY Connectivity

LOGIC AND DISCRETE MATHEMATICS

Bawar Abid Abdalla. Assistant Lecturer Software Engineering Department Koya University

Lecture 8: The Traveling Salesman Problem

Matchings. Examples. K n,m, K n, Petersen graph, Q k ; graphs without perfect matching. A maximal matching cannot be enlarged by adding another edge.

Definition: A graph G = (V, E) is called a tree if G is connected and acyclic. The following theorem captures many important facts about trees.

Logic and Proof course Solutions to exercises from chapter 6

Sets and set operations

Math 485, Graph Theory: Homework #3

Computer Organization and Levels of Abstraction

NP-Complete Reductions 2

Chapter 9 Graph Algorithms

Dr. Chuck Cartledge. 10 June 2015

2. BOOLEAN ALGEBRA 2.1 INTRODUCTION

Discrete Mathematics, Spring 2004 Homework 8 Sample Solutions

Minimum Spanning Tree

implementing the breadth-first search algorithm implementing the depth-first search algorithm

Minimum-Spanning-Tree problem. Minimum Spanning Trees (Forests) Minimum-Spanning-Tree problem

Simple Graph. General Graph

Boolean Algebra. P1. The OR operation is closed for all x, y B x + y B

CSE 215: Foundations of Computer Science Recitation Exercises Set #4 Stony Brook University. Name: ID#: Section #: Score: / 4

Discrete Mathematics Lecture 4. Harper Langston New York University

Homework Assignment #3 Graph

Homework 1. Due Date: Wednesday 11/26/07 - at the beginning of the lecture

LECTURE 4. Logic Design

(Refer Slide Time 3:31)

Algorithms for Minimum Spanning Trees

Transcription:

TA: Jade Cheng ICS 241 Recitation Lecture Notes #12 November 13, 2009 Recitation #12 Question: Use Prim s algorithm to find a minimum spanning tree for the given weighted graph. Step 1. Start from the smallest weight edge, Step 2, 3. Append the smallest edge incidence with,, if the resulting graph does not contain any simple circuit. Then append to,,, or,,, the smallest edge. You ll find the order of, and, doesn t matter. Step 4. Append the smallest edge incidence with,,,,,, if the resulting graph does not contain any simple circuit.

Step 5. Append the smallest edge incidence with,,,,,,,, if the resulting graph does not contain any simple circuit. Step 6. Append the smallest edge incidence with,,,,,,,,,, if the resulting graph does not contain any simple circuit. Step 7. Append the smallest edge incidence with,,,,,,,,,,,, if the resulting graph does not contain any simple circuit. Step 8. Append the smallest edge incidence with,,,,,,,,,,,,,, if the resulting graph does not contain any simple circuit. At this point all vertices are traversed. Prim s algorithm resulted a minimum spanning tree with a total weight of 22, and vertices,,,,,,,,,,,,,,,. Question: Use Kruskal s algorithm to find a minimum spanning tree for the given weighted graph.

Step 1. Start from the smallest weight edge,. Step 2. Append the smallest edges in the rest of the graph, if the resulting graph doesn t contain any simple circuit. Now we have,,,,,. Step 3. Append the smallest edges in the rest of the graph, if the resulting graph doesn t contain any simple circuit. Now we have,,,,,,,,,,,. Step 4. Append the smallest edges in the rest of the graph, if the resulting graph doesn t contain any simple circuit. Now we have,,,,,,,,,,,,,,,. At this point all vertices are traversed. Kruskal s algorithm resulted a minimum spanning tree with a total weight of 22. For this example, the minimum spanning tree resulted by these two different algorithms happen to be the same. This is not always the case, in fact, most of the time, they are different. But the total weight of the minimum spanning tree would always be the same.

Question: Suppose the vertices of are numbered 1, 2, 3, 4, 5 and each edge is assigned a weight equal to the sum of the labels on the endpoints of the edge. Find a spanning tree of minimum weight for this graph. First, we need to construct this weighted simple connected graph and use it as our input for finding the minimum spanning tree. Then we need to construct a minimum spanning tree and count the total weight, which will be the answer of this problem. If we use Kruskal s algorithm: Step 1. 1, 2 Step 2. 1, 2, 1, 3 Step 3. 1, 2, 1, 3, 1, 4 Step 4. 1, 2, 1, 3, 1, 4, 1, 5 At this point all vertices are traversed and the algorithm terminates. The resulting minimum spanning tree has a total weight of 3 4 5 6 18. We can also use Prim s algorithm: Step 1. 1, 2 Step 2. Incidence to 1, 2, append 1, 3

Step 3. Incidence to 1, 2, 1, 3, append 1, 4 Step 4. Incidence to 1, 2, 1, 3, 1, 4, append 1, 5 At this point all vertices are traversed and the algorithm terminates. It happen to be the same tree as the Kruskal s algorithm above. The minimum total weight of the graph is 18. Question: Suppose the vertices of are numbered 1, 2,, (in clockwise order) and each edge is assigned a weight equal to the sum of the labels on the endpoints of the edge. Find a spanning tree of minimum weight for this graph and find the weight of this spanning tree. The spanning tree of minimum cost has edges 1, 2, 1, 3,..., 1,. Using either Kruskal s Algorithm or Prim s Algorithm, the first edges added are 1, 2 and 1, 3. At the next stage, edges 2, 3 and 1, 4 have the smallest weight, but adding edge 2, 3 would create a circuit (circuit containing 2, 3, 1, 2, 1, 3 ). Therefore edges 1, 2, 1, 3, and 1, 4 are inserted into the spanning tree. At the next stage, edges 2, 4 and 1, 5 have the smallest weight, but adding edge 2, 4 would create a circuit (circuit containing 2, 4, 1, 2, 1, 4 ). Therefore edges 1, 2, 1, 3, 1, 4, and 1, 5 are inserted into the spanning tree. In general, if edges 1, 2, 1, 3,, 1, have been selected, the next edge inserted must be 1, 1 (of weight 2). (Any other edge, with weight 2 would have 1 and 1 and would create a circuit when combined with 1, and 1,.) Thus, the spanning tree of minimum weight consists of 1, 2, 1, 3,., 1,.

Its total weight is, therefore, 1 2 1 3 1 4 1 1 2 3 4 2 1 1 2 4 1 2 Question: Review: Find the values of these expressions The Boolean sum, denoted by or OR, has the following values: 1 1 1 1 0 1 0 1 1 0 0 0 The Boolean product, denoted by or by AND, has the following values: 1 1 1 1 0 0 0 1 0 0 0 0 a. 1 0 1 0 1 1 1. b. 1 1 1 1 1 0 1. c. 0 0 0 0 1 0 0. d. 1 0 1 0 1 0. Question: Show that 1 1 0 1 0 1 Following the Boolean operations reviewed above, we can derive the left into the right side, 1. 1 1 0 1 0 1 0 0 1 1 0 1 1 1.

Question: Translate the equation in the previous question into a propositional equivalency by changing each 0 to F, each 1 to a T, each Boolean sum into a disjunction, each Boolean product into a conjunction, each complementation into a negation, and the equals sing to a propositional equivalence sign. 1 1 0 1 0 Question: Prove the idempotent law using the other identities of Boolean algebra listed in Table 5 in the textbook Review: Law of the double complement and 0 and 1 1 1 and 0 0 and and and and and 1 0 Idempotent laws Identity laws Domination laws Commutative laws Associative laws Distributive laws De Morgan s laws Absorption laws Unit property Zero property Follow the Boolean algebra operations we have, 1 0 identity law unit property distributive law zero property identity law Question: Prove the idempotent law 0 0 using the other identities of Boolean algebra listed in Table 5 in the textbook Follow the Boolean algebra operations we have, 0 0 zero property associative law idempotent law zero property

Question: Use a table to express the values of each of these Boolean function. a.,, 1 1 1 0 0 1 1 0 0 0 1 0 1 0 0 1 0 0 0 0 0 1 1 1 1 0 1 0 1 1 0 0 1 1 0 0 0 0 1 0 b.,, 1 1 1 0 0 0 0 0 1 1 0 0 0 0 0 0 1 0 1 0 1 0 1 1 1 0 0 0 1 0 0 0 0 1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 0 1 1 1 0 1 1 0 0 0 1 1 0 0 0 Question: What values of the Boolean variables, satisfies? We can solve this problem by looking over its membership table. 1 1 1 1 1 0 0 1 0 1 0 1 0 0 0 0 The first and last entry contain the same Boolean value for and. Therefore 1, 1 and 0, 0 satisfy the condition. Question: Determine whether or not the following identities hold.

a. The symmetric difference of two sets and is the set containing those elements in either or but not in both and. T T T F T T T F F F T F T T F T F F T T F T T T F F T F T T F F T F T F F F F F By looking at the last two columns, we see that the fourth and eighth entries have the different Boolean values for and. Therefore, the identity does not always hold. In this example, we have a short cut. The left side and right side share a component,. So, basically, the identity is saying the Boolean value does not matter in the Boolean expression. This is obviously not true. When is False, would always be False, the value of doesn t matter. But when is True, and is False, would be False instead of True. b. The symmetric difference of two sets and is the set containing those elements in either or but not in both and. T T T F F T T T T F F T F F T F T T T F F T F F T F T T F T T T F F F F T F T T T T F F T F T T T F F F F F F F By looking at the last two columns, we see that the all of the entries have the same Boolean values for and. Therefore, the identity always holds.

Note that we ve proved that the symmetric difference operation on sets is associative. Dijkstra s Algorithm Review Exercise 2: Find the length of a shortest path between and in the given weighted graph. [12 pts] Let s start from the original graph: Step 1: Step 2: 0 0 2 2 0 3 3 Step 3: Step 4:,,, 0 0 2 2 3 3 2 2 4 4

2 5 7 7 Step 5: Step 6:,,,,,,, 0 0 2 2 3 3 4 4 4 1 5 5 4 4 8 5 2 7 Step 7:,,,, 0 2 3 4 5 7

At this point, vertex, the destination is reached and appended to set, therefore the main loop condition,, can t be satisfied any more. Program exits the loop and terminates. The length is 7 and the path consists vertices:,,,, in this order.