sln-HW01 - CSE450/598 Design And Analysis of Algorithms...

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

View Full Document Right Arrow Icon
CSE450/598 Design And Analysis of Algorithms HW01 Grading Keys 1. (10 pts) Let f ( n ) = 0 . 01 n 2 and g ( n ) = 1000 × n × log 2 ( n + 3). Find the smallest integer N 0 such that f ( N ) g ( N ) but f ( N + 1) > g ( N + 1). Show the values of N , f ( N ), g ( N ), f ( N + 1) and g ( N + 1). Grading Keys: 2 pts for each of the following five values. N = 2100210 , f ( N ) = 44108820441 , g ( N ) = 44108829304 . f ( N + 1) = 44108862445 , g ( N + 1) = 44108851749 . 2. (10 pts) Prove or disprove Θ( n 3 ) + O ( n 4 ) = Θ( n 4 ). Θ( n 3 ) + O ( n 4 ) = Θ( n 4 ) is not true. Proof: Let f ( n ) = n 3 , g ( n ) = n 2 . Then we have f ( n ) Θ( n 3 ) and g ( n ) O ( n 4 ). However, f ( n ) + g ( n ) 6∈ Θ( n 4 ). 2 Grading Keys: 4 pts for the correct conclusion. 6 pts each for the counter example. 3. (10 pts) Exercise 3.5 (p.108) Solutions: Let n ( T ) denote the number of nodes in T . Let n 0 ( T ) denote the number of leaf nodes in T . Let n 1 ( T ) denote the number of nodes in T that has exactly one child. Let n 2 ( T ) denote the number of nodes in T that has exactly two children. Then n ( T ) = n 0 ( T ) + n 1 ( T ) + n 2 ( T ). We need to show that for any binary tree T , we have n 2 ( T ) = n 0 ( T ) - 1 . We prove this by induction on the number of nodes in the binary tree T . When n ( T ) = 1, T has only one node, which is a leaf node. Therefore we have n 0 ( T ) = 1 and n 2 ( T ) = 0. Therefore the claim is true for the base case. Now we assume that the claim is true for any binary tree with k or fewer nodes, for some positive integer k . Let T be a binary tree such that n ( T ) = k + 1. Let v be a leaf node in T . Since n (
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 ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern