ch0 3 - Solutions to Homework One 1 Exercise 0.1(a(b...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Solutions to Homework One CSE 101 1. Exercise 0.1. (a) Θ; (b) O ; (c) Θ; (d) Θ; (l) O ; (m) O ; (n) Θ; (o) Ω; (p) O . 2. Exercise 0.3. (a) Base cases n = 6 and n = 7 are easy to check individually. Now assume the statement holds upto some value of n greater than 6; we need to extend it to n + 1. F n +1 = F n + F n 1 2 0 . 5 n + 2 0 . 5( n 1) (induction hypothesis) 2 · 2 0 . 5( n 1) = 2 0 . 5( n +1) . Note: for this problem (and some of the others below), we need two base cases. Do you see why? (b) We’ll show, again by induction, that F n 2 cn for c = log 2 ((1 + 5) / 2) 0 . 694. The base cases n = 0 , 1 are easy to check. As before, assume the statement is true upto some n > 0; we’ll show it for n + 1: F n +1 = F n + F n 1 2 cn + 2 c ( n 1) = 2 c ( n +1) · (2 c + 2 2 c ) , and the particular value of c chosen satisFes 2 c +2 2 c = 1. (We found c by solving this quadratic equation.) (c) Combined with (b). 3. Exercise 3.5. function reverse ( G ) Input: directed graph G = ( V,E ) in adjacency list format Output: the reverse of G , also in adjacency list format create G R = ( V,E R ) , with edge-set E R initially empty for each u V : for each ( u,w ) E : add edge ( w,u ) to E R return G R ±or each edge ( u,w ) E , adding ( w,u ) to E R takes O (1) time: the edge is simply added to the front of the adjacency list for node w . Thus the total running time is O ( | V
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 3

ch0 3 - Solutions to Homework One 1 Exercise 0.1(a(b...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online