Homework 9 Solutions. 1. (Exercises from the book, 6 th edition, 6.6, 1-3.) Determine the number of distinct orderings of the letters given:

Similar documents
10-701/ Machine Learning, Fall 2005 Homework 3

Problem Set 9 Solutions

Math 261 Exercise sheet 2

= = = (a) Use the MATLAB command rref to solve the system. (b) Let A be the coefficient matrix and B be the right-hand side of the system.

Stanford University CS359G: Graph Partitioning and Expanders Handout 4 Luca Trevisan January 13, 2011

Math 426: Probability MWF 1pm, Gasson 310 Homework 4 Selected Solutions

Math1110 (Spring 2009) Prelim 3 - Solutions

Lecture 10 Support Vector Machines II

Finding Dense Subgraphs in G(n, 1/2)

Section 3.6 Complex Zeros

Example: (13320, 22140) =? Solution #1: The divisors of are 1, 2, 3, 4, 5, 6, 9, 10, 12, 15, 18, 20, 27, 30, 36, 41,

Lectures - Week 4 Matrix norms, Conditioning, Vector Spaces, Linear Independence, Spanning sets and Basis, Null space and Range of a Matrix

Homework Notes Week 7

Inner Product. Euclidean Space. Orthonormal Basis. Orthogonal

find (x): given element x, return the canonical element of the set containing x;

Calculation of time complexity (3%)

Bernoulli Numbers and Polynomials

Solution of Linear System of Equations and Matrix Inversion Gauss Seidel Iteration Method

Supplement: Proofs and Technical Details for The Solution Path of the Generalized Lasso

2.3 Nilpotent endomorphisms

MAE140 - Linear Circuits - Fall 13 Midterm, October 31

NP-Completeness : Proofs

THE CHINESE REMAINDER THEOREM. We should thank the Chinese for their wonderful remainder theorem. Glenn Stevens

n α j x j = 0 j=1 has a nontrivial solution. Here A is the n k matrix whose jth column is the vector for all t j=0

Implicit Integration Henyey Method

UNIVERSITY OF UTAH ELECTRICAL & COMPUTER ENGINEERING DEPARTMENT. 10k. 3mH. 10k. Only one current in the branch:

Modelli Clamfim Equazione del Calore Lezione ottobre 2014

Maximal Margin Classifier

Math 217 Fall 2013 Homework 2 Solutions

Introduction to Algorithms

FE REVIEW OPERATIONAL AMPLIFIERS (OP-AMPS)( ) 8/25/2010

ISQS 6348 Final Open notes, no books. Points out of 100 in parentheses. Y 1 ε 2

x = , so that calculated

MAE140 - Linear Circuits - Winter 16 Final, March 16, 2016

THE ARIMOTO-BLAHUT ALGORITHM FOR COMPUTATION OF CHANNEL CAPACITY. William A. Pearlman. References: S. Arimoto - IEEE Trans. Inform. Thy., Jan.

Errors for Linear Systems

Exercises. 18 Algorithms

U.C. Berkeley CS294: Beyond Worst-Case Analysis Luca Trevisan September 5, 2017

E Tail Inequalities. E.1 Markov s Inequality. Non-Lecture E: Tail Inequalities

First day August 1, Problems and Solutions

Introduction to Vapor/Liquid Equilibrium, part 2. Raoult s Law:

Mathematics Intersection of Lines

COMPLEX NUMBERS AND QUADRATIC EQUATIONS

(2mn, m 2 n 2, m 2 + n 2 )

Min Cut, Fast Cut, Polynomial Identities

Section 8.3 Polar Form of Complex Numbers

Dynamic Programming. Preview. Dynamic Programming. Dynamic Programming. Dynamic Programming (Example: Fibonacci Sequence)

CS 331 DESIGN AND ANALYSIS OF ALGORITHMS DYNAMIC PROGRAMMING. Dr. Daisy Tang

PHYSICS - CLUTCH CH 28: INDUCTION AND INDUCTANCE.

Grover s Algorithm + Quantum Zeno Effect + Vaidman

Our focus will be on linear systems. A system is linear if it obeys the principle of superposition and homogenity, i.e.

Attacks on RSA The Rabin Cryptosystem Semantic Security of RSA Cryptology, Tuesday, February 27th, 2007 Nils Andersen. Complexity Theoretic Reduction

11 Tail Inequalities Markov s Inequality. Lecture 11: Tail Inequalities [Fa 13]

Week3, Chapter 4. Position and Displacement. Motion in Two Dimensions. Instantaneous Velocity. Average Velocity

Physics 2A Chapter 3 HW Solutions

CHAPTER 17 Amortized Analysis

= z 20 z n. (k 20) + 4 z k = 4

8.4 COMPLEX VECTOR SPACES AND INNER PRODUCTS

CHAPTER IV RESEARCH FINDING AND DISCUSSIONS

APPENDIX A Some Linear Algebra

Complex Numbers. x = B B 2 4AC 2A. or x = x = 2 ± 4 4 (1) (5) 2 (1)

1 (1 + ( )) = 1 8 ( ) = (c) Carrying out the Taylor expansion, in this case, the series truncates at second order:

Physics 40 HW #4 Chapter 4 Key NEATNESS COUNTS! Solve but do not turn in the following problems from Chapter 4 Knight

( ) 2 ( ) ( ) Problem Set 4 Suggested Solutions. Problem 1

The path of ants Dragos Crisan, Andrei Petridean, 11 th grade. Colegiul National "Emil Racovita", Cluj-Napoca

Generalized Linear Methods

a b a In case b 0, a being divisible by b is the same as to say that

Multi-dimensional Central Limit Theorem

Affine and Riemannian Connections

18.781: Solution to Practice Questions for Final Exam

ACTM State Calculus Competition Saturday April 30, 2011

Problem Set 6: Trees Spring 2018

Quantum Mechanics I - Session 4

CHALMERS, GÖTEBORGS UNIVERSITET. SOLUTIONS to RE-EXAM for ARTIFICIAL NEURAL NETWORKS. COURSE CODES: FFR 135, FIM 720 GU, PhD

PHYS 705: Classical Mechanics. Calculus of Variations II

ρ some λ THE INVERSE POWER METHOD (or INVERSE ITERATION) , for , or (more usually) to

Graphical Analysis of a BJT Amplifier

1. Estimation, Approximation and Errors Percentages Polynomials and Formulas Identities and Factorization 52

36.1 Why is it important to be able to find roots to systems of equations? Up to this point, we have discussed how to find the solution to

G4023 Mid-Term Exam #1 Solutions

Section 8.1 Exercises

Chapter Newton s Method

Computing Correlated Equilibria in Multi-Player Games

For now, let us focus on a specific model of neurons. These are simplified from reality but can achieve remarkable results.

Foundations of Arithmetic

Quantum Mechanics for Scientists and Engineers. David Miller

U.C. Berkeley CS294: Spectral Methods and Expanders Handout 8 Luca Trevisan February 17, 2016

Lecture 10: May 6, 2013

Module 9. Lecture 6. Duality in Assignment Problems

Chapter 2 Math Fundamentals

Answers Problem Set 2 Chem 314A Williamsen Spring 2000

Lecture Notes on Linear Regression

5 The Rational Canonical Form

xp(x µ) = 0 p(x = 0 µ) + 1 p(x = 1 µ) = µ

Numerical Algorithms for Visual Computing 2008/09 Example Solutions for Assignment 4. Problem 1 (Shift invariance of the Laplace operator)

Power-sum problem, Bernoulli Numbers and Bernoulli Polynomials.

ÉCOLE POLYTECHNIQUE FÉDÉRALE DE LAUSANNE

MATH 5707 HOMEWORK 4 SOLUTIONS 2. 2 i 2p i E(X i ) + E(Xi 2 ) ä i=1. i=1

International Mathematical Olympiad. Preliminary Selection Contest 2012 Hong Kong. Outline of Solutions

1 GSW Iterative Techniques for y = Ax

Transcription:

Homework 9 Solutons PROBLEM ONE 1 (Exercses from the book, th edton,, 1-) Determne the number of dstnct orderngs of the letters gven: (a) GUIDE Soluton: 5! (b) SCHOOL Soluton:! (c) SALESPERSONS Soluton: 1! 4!! (Exercses from the book, th edton,, 4-5) (a) In how many ways can we order the letters of SALESPER- SONS so that all four S characters are adacent? Soluton: Snce the four Ss must be adacent, we may group them together and move them together Therefore we can magne that we have now 9 obects: SSSS, A, L, E, P, E, R, O, N We permute these obects, notng that now there are only two dentcal obects: both Es Therefore there are 9!! orderngs (b) In how many ways can we order the letters of SALESPER- SONS so that no two S characters are adacent? Soluton: Ths s a very dffcult problem unless you use the method outlned n the book I wll explan ths method n a separate handout Please look for ths on the course webste PROBLEM TWO (Pascal s Trangle) In class, we showed that for any n 1 and k wth 1 k n, we have k n 1 k 1 Recall that ths notaton means ( ) ( ) ( ) n k 1 k + k k 1 k 1 1 ( ) k 1 + + 1 k 1

If we plug n for k we get ( ) 1 + 1 ( ) + + 1 and snce ( ) n n! (n )!! n(n 1), we get n(n 1) 1 Use k to fnd the sum of 1 1 1 + + + (n 1) (1) 1 + + + 10 + + Soluton: Puttng k nto the dentty above, we get ( ) + ( ) + + n(n 1) () ( n 1 Snce ( ) n n(n 1)(n ) and snce for each k, ( ) k k(k 1), we get n(n 1)(n ) 1 + + + + In ths equaton, plug n n + 1 for n to get 1 + + + + n(n 1) ) (n 1)(n ) (n + 1)n(n 1) Can you use both formulas (1) and () to fnd the sum 1 + 4 + + n? Soluton: We can rewrte the answer to the last queston as k(k 1) + 1 + 1 (k k) k + 1 k + 1 k + k

However, we know from (1) that n k n+1 Therefore ( ) ( ) n + 1 n + 1 k + (n + 1)n(n 1) (n + 1)n + [ n 1 (n + 1)n + 1 ] n(n + 1)(n + 1) Gve two arguments (one whch uses factorals and one whch s more heurstc, usng n obects etc) to show that ( ) ( ) n n k n k Soluton: To show usng factorals, we have n k n! (n k)!(n (n k))! n! (n k)!k! n! k!(n k)! k Now we argue usng combnatons etc Suppose that we have n obects and 1 bn We choose k of these obects and place them n bn 1 The number of ways we can do ths s ( n k) Instead of choosng k obects to place n bn 1, we could have chosen n k obects not to place n bn 1 the number of ways to do ths should be exactly the same, and ths number s ( n n k) PROBLEM THREE (Inserton Sort) Exercses for problem three: 1 Trace through ths algorthm, showng lsts wth arrows at each step (as I dd) Use the ntal data 11, 4,, 10, 0, EOL Soluton: Lst A 11 4 10 0 EOL 11 EOL

Lst A 11 4 10 0 EOL 4 11 EOL 4 11 EOL Lst A 11 4 10 0 EOL 4 11 EOL 4 11 EOL Lst A 11 4 10 0 EOL 4 11 EOL 4 11 EOL 4 10 11 EOL 4 10 11 EOL Lst A 11 4 10 0 EOL 0 4 10 11 EOL 0 4 10 11 EOL Lst A 11 4 10 0 EOL Here s some pseudocode whch should perform the nserton sort It assumes that the lst A has sze at least 1 4

lne code 1 1 create the lst B wth two characters: A(1) and EOL 4 whle(a() EOL) { 5 whle(a() B() and B() EOL) { + 1 } 7 place A() drectly before spot n lst B 8 1 9 + 1 } 10 Return B Trace through ths algorthm (show the status of each of the varables at each change) for the ntal data A 11, 4,, 10, 0, EOL Each tme a varable does not change, you may wrte a dash ( ) for that varable n the tracng table Soluton: Lst A 11,4,,10,0,EOL?????? 1 11,EOL 4,11,EOL,4,11,EOL 4,4,10,11,EOL 1 5 0,,4,10,11,EOL Gve a lst A wth elements whch gves the worst-case number of lnes executed How many lnes s ths? Soluton: A worst-case lst wth elements s 1,,, EOL In ths case, the algorthm executes 1 lnes 4 Gve a lst B wth elements whch gves the best-case number of lnes executed How many lnes s ths? Soluton: A best-case lst wth elements s,, 1, EOL In ths case, the algorthm executes 15 lnes 5

5 For a lst of n elements, what s the worst-case number of lnes executed? What s the best-case number of lnes executed? How do these numbers compare to those we found n class for the bubble sort? Are there cases n whch the nserton sort s better? Are there cases n whch t s worse? Soluton: The worst-case number of lnes s n + 4n Ths was computed on the homework hnt sheet The best-case number of lnes s 5n Ths can be seen as follows In the best case, we never enter the nner loop Therefore, durng each pass through the outer loop we execute 5 lnes (lnes 4, 5, 7, 8, and 9) The outer loop s executed as moves from to n Ths s n 1 tmes So we get a total of + 5(n 1) + 5n lnes lnes 1- outer loop fal outer loop and ext The bubble sort executed a number of lnes whch was on the order of n (e ts run-tme was θ(n )), regardless of the nput Therefore the nserton sort s much better for nput lsts whch are already sorted, but n decreasng order (ths was the best-case for nserton sort) For example, the lst 10, 9, 8,, 1, EOL wll sort much faster under nserton sort For some lsts, the nserton sort executes a number of lnes whch s on the order of n (e t s θ(n )) For these lsts, both sort algorthms perform relatvely the same Whether or not there exst a lst whch sorts faster under bubble sort s a queston that I wll have to answer later I dd not wrte down the exact number of lnes executed (whch we computed n class) for bubble sort