# cs161___Homework_1.pdf - CS 161 (Stanford, Winter 2022)...

• 8

Course Hero uses AI to attempt to automatically extract content from documents to surface to you and others so you can study better, e.g., in search results, to enrich docs, and more. This preview shows page 1 - 3 out of 8 pages.

CS 161 (Stanford, Winter 2022)Homework 1Style guide and expectations:Please see the “Homework” part of the “Resources” sec-tion on the webpage for guidance on what we are looking for in homework solutions. Wewill grade according to these standards. You should cite all sources you used outside ofthe course material.What we expect:Make sure to look at the “We are expecting” blocks below eachproblem to see what we will be grading for in each problem!Exercises.The following questions are exercises. We suggest you do these on your own.As with any homework question, though, you may ask the course staff for help.1Exercise: Course policies(1 pt.)Have you thoroughly read the course policies on the webpage?Yes2Exercise: Big-Oh Basics(2 pt.)Which of the following functions areO(n2)?No explanation is required, but you might want to prove your answer to yourself to convinceyourself that you are correct.
1
f5(n) = sin(n) + 5f7(n) = (1003)43Exercise: Big-Oh DefinitionsTerry the Terrific Tiger wants to prove, from the definition of big-Oh, thatf(n) =O(g(n)),wheref(n) = 6nandg(n) =n23n.3.1c=1(2 pt.)In the definition of big-Oh, Terry really wants to takec= 1.Give a proof thatf(n) =O(g(n))in which "c" is chosen to be 1.3.2n0=4(2 pt.)Terry has changed their mind. Now, they don’t care whatcis, but would like to taken0= 4. Give a different proof thatf(n) =O(g(n))in which "n0" is chosen to be 4.3.1:We want to prove thatf(n) =O(g(n)), meaning that we have to prove, from the definitionof big-Oh, thatc, n0>0s.tnn0, f(n)c·g(n)wherecis chosen to be1.Letn0= 9. We will prove thatf(n)c·g(n)holds for allnn0, wherec= 1. We cansimplify the inequality:f(n)1·g(n)(1)6nn23n(2)0n29n(3)Solving gives usn9, so we can see that for alln9,f(n)1·g(n)holds. Therefore,we have proven thatf(n)1·g(n)holds for allnn0wheren0= 9, which proves thatf(n) =O(g(n)).3.2:We want to prove thatf(n) =O(g(n)), meaning that we have to prove, from the definitionof big-Oh, thatc, n0>0s.tnn0, f(n)c·g(n)wheren0is chosen to be4.

Course Hero member to access this document

Course Hero member to access this document

End of preview. Want to read all 8 pages?

Course Hero member to access this document

Term
Fall
Professor
NoProfessor
Tags
Elon Tusk