# Register now to access 7 million high quality study materials (What's Course Hero?) Course Hero is the premier provider of high quality online educational resources. With millions of study documents, online tutors, digital flashcards and free courseware, Course Hero is helping students learn more efficiently and effectively. Whether you're interested in exploring new subjects or mastering key topics for your next exam, Course Hero has the tools you need to achieve your goals.

4 Pages

### hw2_solutions

Course: CSCI 303, Spring 2010
School: USC
Rating:

Word Count: 1045

#### Document Preview

303 CSCI Homework 2 Problem 1 (4.3-2): The recurrence T (n) = 7T (n/2) + n2 describes the running time of an algorithm A. A competing algorithm A has a running time of T (n) = aT (n/4) + n2 . What is the largest integer value for a such that A is asymptotically faster than A? Solution 1: By the master theorem, the worst-case asymptotic complexity of A is (nlg 7 ) (n2.80735 ), and the worst-case asymptotic...

Register Now

#### Unformatted Document Excerpt

Coursehero >> California >> USC >> CSCI 303

Course Hero has millions of student submitted documents similar to the one
below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

Course Hero has millions of student submitted documents similar to the one below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.
303 CSCI Homework 2 Problem 1 (4.3-2): The recurrence T (n) = 7T (n/2) + n2 describes the running time of an algorithm A. A competing algorithm A has a running time of T (n) = aT (n/4) + n2 . What is the largest integer value for a such that A is asymptotically faster than A? Solution 1: By the master theorem, the worst-case asymptotic complexity of A is (nlg 7 ) (n2.80735 ), and the worst-case asymptotic complexity of A is (nlog4 a ), if a > 16. For A to be asymptotically faster than A, log4 a < lg 7 = log4 49. Therefore, the largest integer value for a such that A is asymptotically faster than A is 48. Problem 2 (Derived from 4-1 and 4-4): Give asymptotic upper and lower bounds for T (n) in each of the following recurrences. Make your bounds as tight as possible, and justify your answers. a. T (n) = 2T (n/2) + n3 . b. T (n) = 16T (n/4) + n2 . c. T (n) = 7T (n/3) + n2 . d. T (n) = 7T (n/2) + n2 . e. T (n) = 2T (n/4) + n. f. T (n) = 3T (n/2) + n lg n. g. T (n) = 4T (n/2) + n2 n. h. T (n) = T (9n/10) + n. Solution 2: Use the master method to solve these recurrences. a. Case 3 of master theorem. T (n) = (n3 ). b. Case 2 of master theorem. T (n) = (n2 lg n). c. Case 3 of master theorem. T (n) = (n2 ). d. Case 1 of master theorem. T (n) = (nlg 7 ). e. Case 2 of master theorem. T (n) = ( n lg n). f. Case 1 of master theorem. T (n) = (nlg 3 ). g. Case 3 of master theorem. T (n) = (n2 n). h. Case 3 of master theorem. T (n) = (n). Problem 3 (Derived from 4-1 and 4-4): Give asymptotic upper and lower bounds for T (n) in each of the following recurrences. Make your bounds as tight as possible, and justify your answers. You may assume that T (1) is a constant. a. T (n) = T (n - 1) + n. 1 b. T (n) = T (n - 1) + 1/n. c. T (n) = T (n - 1) + lg n. d. T (n) = 2T (n/2) + n lg n. e. T (n) = 5T (n/5) + n/ lg n. Solution 3: For these recurrences, the master theorem does not apply. a. Assume T (1) = 1, then unroll the recurrence: T (n) = T (n - 1) + n = n + (n - 1) + (n - 2) + + 2 + T (1) n = k=1 k = n(n + 1) 2 = (n2 ) b. Assume T (1) = 1, then unroll the recurrence: T (n) = T (n - 1) + = = k=1 1 1 n + n-1 n 1 n 1 n-2 + + + 1 2 + 1 T (1) 1 k We can bound this sum using integrals (see appendix A.2 in the book, equations A.11A.14). n T (n) = 1 k=1 n+1 1 k n T (n) = k=1 1 k n 1 dx x =1+ k=2 n 1 k 1 dx x = ln(n + 1) ln n = (ln n) 1+ 1 = 1 + ln n = O(ln n) T (n) = (ln n) = (lg n) 2 c. Assume T (1) = 1, then unroll the recurrence: T (n) = T (n - 1) + lg n = lg n + lg(n - 1) + lg(n - 2) + + lg 2 + lg 1 n = k=1 lg k n = lg k=1 k = lg(n!) = (n lg n) By Stirling's approximation (see section 3.2 in the book, equation 3.18). d. Assume n = 2m for some m and T (1) = c, then unroll the recurrence: T (n) = 2T n 2 + n lg n n 4 = 2 2T + n 8 n 2 lg n + n lg n 2 n 4 = 2 2 2T + lg n + 4 n 2 lg n + n lg n 2 n 4 = 2 2 2 (2 (2T (1) + 2 lg 2) + 4 lg 4) + + = n(c + lg 2 + lg 4 + + lg n + lg n + lg n) 4 n lg 2 lg n + 4 n 2 lg n + n lg n 2 =n c+ k=1 k lg2 n+lg n 2 =n c+ = 1 n lg2 n + 1 n lg n + cn 2 2 = (n lg2 n) e. Assume n = 5m for some m and T (1) = c, then unroll the recurrence: T (n) = 5T n 5 + n/ lg n n 25 = 5 5T + n / lg n + n/ lg n 5 5 n n 25 / lg 25 = 5 5 5 (5 (5T (1) + 5/ lg 5) + 25/ lg 25) + + + n / lg n + n/ lg n 5 5 n = n(c + 1/ lg 5 + 1/ lg 52 + + 1/ lg 52 + 1/ lg n + 1/ lg n 5 log5 n 1 = n c + lg 5k k=1 n = nc + lg 5 log5 n k=1 1 k = (n lg lg n) Problem 4 (Not in book): The following algorithm uses a divide-and-conquer strategy to search an unsorted list of numbers. 3 Given a list of numbers A and a target number t, the algorithm returns 1 if t it is in the list, and 0 otherwise. Unsorted-Search(A, t, p, q) if q - p < 1 if A[p] = t return 1 else return 0 if Unsorted-Search(A, t, p, p+q ) = 1 return 1 2 if Unsorted-Search(A, t, p+q + 1, q) = 1 return 1 2 return 0 Analyze this algorithm with respect to worst-case asymptotic complexity, and give the worst-case running time in terms of notation. How does this algorithm compare to the naive algorithm that simply iterates through the list to look for the target? Solution 4: The algorithm is given an array of n numbers and a target number. The first two lines take constant time, call it c. The next two lines recursively call Unsorted-Search on inputs of size n/2. Therefore, the worst-case asymptotic complexity is T (n) = 2T (n/2) + c Using case 1 of the master theorem, we see that T (n) = (n). This is the same worst-case asymptotic complexity as the naive algorithm, although in practice the naive algorithm would probably run more quickly. Problem 5 (28.2-4): V. Pan has discovered a way of multiplying 68 68 matrices using 132,464 multiplications, a way of multiplying 70 70 matrices using 143,640 multiplications, and a way of multiplying 72 72 matrices using 155,424 multiplications. Which method yields the best asymptotic running time when used in a divide-and-conquer matrix-multiplication algorithm? How does it compare to Strassen's algorithm? Solution 5: For each case, we write the recurrence and solve it using the master theorem: (1) (2) (3) T (n) = 132464T (n/68) + n2 T (n) = 143640T (n/70) + n2 T (n) = 155424T (n/72) + n2 T (n) = (nlog68 132464 ) (n2.795128 ) T (n) = (nlog70 143640 ) (n2.795123 ) T (n) = (nlog72 155424 ) (n2.795147 ) Strassen's algorithm runs in (nlg 7 ) (n2.81 ), so all these algorithms outperform Strassen. Problem 6 (28.2-6): Show how to multiply the complex numbers a + bi and c + di using only three real multiplications. The algorithm should take a, b, c, and d as input and produce the real component ac - bd and the imaginary component ad + bc separately. Solution 6: Let r = (a + b)(c + d) = ac + ad + bc + bd, let s = ac, and let t = bd. Then the real component of the product of the two complex numbers is ac - bd = s - t and the imaginary component of the two complex numbers is ad + bc = r - s - t. 4
Find millions of documents on Course Hero - Study Guides, Lecture Notes, Reference Materials, Practice Exams and more. Course Hero has millions of course specific materials providing students with the best way to expand their education.

Below is a small sample set of documents:

USC - CSCI - 303
CSCI 303 Homework 3Problem 1 (9-1): Given a set A of n numbers, we wish to nd the k largest in sorted order using a comparisonbased algorithm. Find the algorithm that implements each of the following methods with the best asymptotic worst-case running ti
USC - CSCI - 303
CSCI 303 Homework 3Problem 1 (9-1): Given a set A of n numbers, we wish to nd the k largest in sorted order using a comparisonbased algorithm. Find the algorithm that implements each of the following methods with the best asymptotic worst-case running ti
USC - CSCI - 303
CSCI 303 Homework 4Problem 1 (6.1-1): What are the minimum and maximum numbers of elements in a heap of height h? Problem 2 (6.1-6): Is the sequence 23, 17, 14, 6, 13, 10, 1, 5, 7, 12 a max-heap? Problem 3 (6.2-1): Using Figure 6.2 as a model, illustrate
USC - CSCI - 303
CSCI 303 Homework 4Problem 1 (6.1-1): What are the minimum and maximum numbers of elements in a heap of height h? Solution 1: A heap is a semi-complete binary tree, so the minimum number of elements in a heap of height h is 2h , and the maximum number of
USC - CSCI - 303
CSCI 303 Homework 5Problem 1 (Not in book): Using the polynomial time reduction given in class, give an instance of the Directed Hamiltonian Cycle problem that corresponds to the instance of the 3-SAT problem where = (x1 x2 x3 ) (x1 x2 x1 ) (x2 x2 x3 ).
USC - CSCI - 303
CSCI 303 Homework 5Problem 1 (Not in book): Using the polynomial time reduction given in class, give an instance of the Directed Hamiltonian Cycle problem that corresponds to the instance of the 3-SAT problem where = (x1 x2 x3 ) (x1 x2 x1 ) (x2 x2 x3 ).
USC - CSCI - 303
CSCI 303 Homework 6Problem 1 (31.1-1): Prove that there are innitely many primes. Problem 2 (31.1-7): For any integer k &gt; 0, we say that an integer n is a kth power if there exists an integer a such that ak = n. We say that n &gt; 1 is a nontrivial power if
USC - CSCI - 303
CSCI 303 Homework 6Problem 1 (31.1-1): Prove that there are innitely many primes. Solution 1: Assume that there are only nitely many primes, p1 , p2 , . . . , pk . Letkn=1+i=1piThen for all i cfw_1, 2, . . . , k , if you divide n by pi the remainder
USC - CSCI - 303
CSCI 303 Homework 7In the following problems, N = cfw_1, 2, 3, . . . is the set of natural numbers, the symbol means there exists, the symbol means for all, the symbol means halts, and the symbol means does not halt. Bi (x) is the ith SBASIC program run
USC - CSCI - 303
CSCI 303 Homework 7In the following problems, N = cfw_1, 2, 3, . . . is the set of natural numbers, the symbol means &quot;there exists&quot;, the symbol means &quot;for all&quot;, the symbol means &quot;halts&quot;, and the symbol means &quot;does not halt&quot;. Bi (x) is the ith SBASIC prog
University of Texas - MATH - 340L
University of Texas - MATH - 340L
University of Texas - MATH - 340L
Griggs - ECON - 110
Griggs - ECON - 110
COMPUTERS ARE YOUR FUTURECHAPTER 3WIRED &amp; WIRELESS COMMUNICATIONWired and Wireless Transmission MediaShort Answer Questions: Submit your written answers to the instructor.1. Complete the following table. Rank the wired and wireless transmission media
Griggs - ECON - 110
COMPUTERS ARE YOUR FUTURESPOTLIGHT 3HOME NETWORKSConvergenceDiscussion Questions: Be prepared to discuss the following questions in class.1. The future of home networking is convergencethat is, tying in other home devices such asappliances, alarm sy
Griggs - ECON - 110
COMPUTERS ARE YOUR FUTURECHAPTER 3WIRED &amp; WIRELESS COMMUNICATIONWired and Wireless CommunicationDiscussion Questions: Be prepared to discuss the following questions in class.1. Wireless networking technology is becoming popular because it offers mobi
Griggs - ECON - 110
COMPUTERS ARE YOUR FUTURECHAPTER 3WIRED &amp; WIRELESS COMMUNICATIONConferencing Applications1. Because of the increased availability and reduced cost of network connectivity, thefield of conferencing has grown tremendously. Research and define the follo
Griggs - ECON - 110
Griggs - ECON - 110
COMPUTERS ARE YOUR FUTURECHAPTER 3WIRED &amp; WIRELESS COMMUNICATIONWired and Wireless ApplicationsShort Answer Questions: Submit your written answers to the instructor.1. Many people are eliminating the use of landlines from their homes. What types of
Griggs - ECON - 110
Griggs - ECON - 110
Griggs - ECON - 110
COMPUTERS ARE YOUR FUTURECHAPTER 5APPLICATION SOFTWARE:TOOLS FOR PRODUCTIVITYApplication SoftwareShort Answer Questions: Submit your written answers to the instructor.1. Companies must decide between building customized software and purchasing off-t
Griggs - ECON - 110
COMPUTERS ARE YOUR FUTURECHAPTER 5APPLICATION SOFTWARE:TOOLS FOR PRODUCTIVITYBuy versus BuildShort Answer Questions: Submit your written answers to the instructor.1. Imagine that you are the head of the accounting department, and you need to decide
Griggs - ECON - 110
COMPUTERS ARE YOUR FUTURECHAPTER 5APPLICATION SOFTWARE:TOOLS FOR PRODUCTIVITYApplication Software1. Companies sometimes use additional programmers from other countries to helpthem develop or maintain applications. What are some of the reasons that a
Griggs - ECON - 110
COMPUTERS ARE YOUR FUTURESPOTLIGHT 5MICROSOFT OFFICECollaborationDiscussion Questions: Be prepared to discuss the following questions in class.1. Collaboration is defined as the technologies and tools that enable users to access information, sharein
Griggs - ECON - 110
COMPUTERS ARE YOUR FUTURESPOTLIGHT 5MICROSOFT OFFICEOffice ToolsShort Answer Questions: Submit your written answers to the instructor.1. The success of the Microsoft Office suite is due to its full functionality and its integration. Which products i
Griggs - ECON - 110
COMPUTERS ARE YOUR FUTURECHAPTER 5APPLICATION SOFTWARE:TOOLS FOR PRODUCTIVITYApplication Software Upgrades and LicensingDiscussion Questions: Be prepared to discuss the following questions in class.1. Software vendors routinely release new applicati
Griggs - ECON - 110
Chapter 1. Key term and conceptsalgorithmA mathematical or logical procedure for solving a pA system unit that contains all of the coall-in-one computercomponents, including input components and the diPrograms that enable you to do something useful
Griggs - ECON - 110
Chapter 2: The Internet and the World Wide WebAn Internet service that enables you to contact a distant computer system to which you have no accessanonymous FTPrights, log on to its public directories, and transfer files from that computer to your own.
Griggs - ECON - 110
applicationsoftwareProgramsthatenableyoutodosomethingusefulwiththecomputer,suchas writingoraccounting(asopposedtoutilities,whichareprogramsthathelpyou maintainthecomputer).autosaveAsoftwarefeaturethatbacksupopendocumentsatauserspecifiedinterval.bet
Griggs - ECON - 110
Chapter 32G Second-generation cellular techonology that quickly replaced most analogcellular services.3G Third- generation cellular techonology that user radio signals to transmitvoice, text, images, and video data.4G Fourth- generation cellular tech
Griggs - ECON - 110
1,2/30System software : All the software used to operate and maintain a computer system,including the operating system and utility programs.There are 2 types of software : system software and application software.Application software : Programs that e
Griggs - ECON - 110
1. - Describe my experiences with the Internet: I usually read news on the Internet and I always use yahoo messenger to chat withmy friends.- Identify the browser and e-mail software application that you have used: I have used the Mozilla firefox and
Griggs - ECON - 110
1.What is the difference between bandwidth and throughput? What Internetapplications require high bandwidth?Bandwidth: is the theoretical maximum amount of data that can be sent through a specifictransmission medium at one time (per second)Throughput
Griggs - ECON - 110
1. What is the difference between bandwidth and throughput? What Internet applicationsrequire high bandwidth?Bandwidth: is the theoretical maximum amount of data that can be sent through a specifictransmission medium at one time (per second)Throughput
Griggs - ECON - 110
3/214Share wareUse on try before you buybasic. After using for aspecificed trial period, youmust pay a registration feeor violate the copyrightEx: IDM, surprise software4/214Free wareGiven away for free, cantturn around and sell it forprofitP
Griggs - ECON - 110
IntroductiontoComputerbyDr.NguyenMinhHoangSaigonICT,HVUhoang.dhbk@gmail.com20111LecturesnnCoursename:IntroductiontoComputer(CPTR105)No.ofSessions:14+2exams(midterm&amp;final)nnThursday(8:30AM11:30AM)3hours/weekOfficehoursnnAfterlecturestimeo
Griggs - ECON - 110
IntroductiontoComputerSpotlight1:EthicsbyDr.NguyenMinhHoangSaigonICT,HVUhoang.dhbk@gmail.com2011@byDr.NguyenMinhHoang,SaigonICT,HVU,20111ComputersAreYourFutureTenthEditionSpotlight1:EthicsCopyright 2009 Pearson Education, Inc. Publishing as Pr
Griggs - ECON - 110
Griggs - ECON - 110
Griggs - ECON - 110
IntroductiontoComputerApplicationSoftware:Internetprograms1@byDr.NguyenMinhHoang,SaigonICT,HVU,2011WhatwewilllearnnnnHelpuserscommunicate,learn,andinteractthroughtheInternetThesessioncovers:Email,IMsoftware,Webbrowsers,VideoconferencingMicroso
Griggs - ECON - 110
IntroductiontoComputerbyDr.NguyenMinhHoangSaigonICT,HVUhoang.dhbk@gmail.com20101LecturesnnCoursename:IntroductiontoComputer(CPTR105)No.ofSessions:14+2exams(midterm&amp;final)nnThursday(8:30AM11:30AM)3hours/weekOfficehoursnnAfterlecturestimeo
Griggs - ECON - 110
IntroductiontoComputerSpotlight1:EthicsbyDr.NguyenMinhHoangSaigonICT,HVUhoang.dhbk@gmail.com2010@byDr.NguyenMinhHoang,SaigonICT,HVU,20101ComputersAreYourFutureTenthEditionSpotlight1:EthicsCopyright 2009 Pearson Education, Inc. Publishing as Pr
Griggs - ECON - 110
Griggs - ECON - 110
Griggs - ECON - 110
Griggs - ECON - 110
IntroductiontoComputerLecture3:Wired&amp;WirelessCommunication1@byDr.NguyenMinhHoang,SaigonICT,HVU,2010@byDr.NguyenMinhHoang,SaigonICT,HVU,2010Wired&amp;WirelessCommunication2@byDr.NguyenMinhHoang,SaigonICT,HVU,2010WhatYouWillLearnnnnDefinebandwidthan
Griggs - ECON - 110
A(n) _bit_ is the smallest piece of information with which a computer can work.Because a computer uses direct current (DC) and wall outlets use alternating current (AC), a(n) _power supply _ is needed to convert the current.The _ motherboard _ is the
Griggs - ECON - 110
CHNG TRNH O TO C NHN QUN TR KINH DOANH QUC TWebsite: www.griggs.edu.vn Email: gabba@griggs.edu.vnINTRODUCTIONTOCOMPUTERTESTBANKTimeallocated:120minutes.Chapter 6 Inside the System Unit1) Hardware performance:A) is independent of the operating system
Griggs - ECON - 110
Griggs - ECON - 110
Short Answer1. Explain the difference between RAM and ROM. Why are both types of memory used in acomputer?RAM, which means random access memory, is volatile. The contents of RAM will beerased when a computer is turned off. ROM, which means read-only m
Griggs - ECON - 110
Short Answer1. If you have used a notebook computer, which of the various pointing devicestrackball,touchpad, or pointing stickhave you used? Which input device do you prefer? Explainwhy. Would you consider using an auxiliary mouse (a regular mouse tha
Griggs - ECON - 110
HUMANITIESNguyen, Ngoc ThoVice Dean, Faculty of Culturology,University of Social Sciences and HumanitiesCHINESE PHILOSOPHY1. Yin-yang philosophya. Dualism T duy lng phnAll of nature are considered to be in pairs. Ex: tall-short;fat-slim, beautiful
Griggs - ECON - 110
HUMANITIESNguyen, Ngoc ThoVice Dean, Faculty of Culturology,University of Social Sciences and HumanitiesIV- TRADITIONAL BELIEFS AND RELIGIONS1. Traditional beliefs+ Fertility worshipsWishes of fertility of (1) the nature (the crops); (2) humanbein
Griggs - ECON - 110
HUMANITIESNguyen, Ngoc ThoVice Dean, Faculty of Culturology,University of Social Sciences and HumanitiesV- PERFORMING ARTS1. Practical trainings-Thai danceKhmer danceLao danceRussian danceSamba danceBy Thuong Cong Minh and Phan Hong Diem Linh
Griggs - ECON - 110
HUMANITIESNguyen, Ngoc ThoVice Dean, Faculty of Culturology,University of Social Sciences and HumanitiesIII- COGNITIVE CULTURE1. Yin-yang philosophya. Dualism T duy lng phnAll of nature are considered to be in pairs. Ex: tall-short;fat-slim, beaut
Griggs - ECON - 110
HUMANITIESNguyen, Ngoc ThoVice Dean, Faculty of Culturology,University of Social Sciences and HumanitiesII- PHILOSOPHY1. Oriental philosophiesd. Chinese philosophyII- PHILOSOPHY1. Oriental philosophiesd. Chinese philosophyXia-Shang-Zhou-Qin-Han-
Griggs - ECON - 110
IntroductiontoComputerbyDr.NguyenMinhHoangSaigonICT,HVUhoang.dhbk@gmail.com20101LecturesnnCoursename:IntroductiontoComputer(CPTR105)No.ofSessions:14+2exams(midterm&amp;final)nnThursday(8:30AM11:30AM)3hours/weekOfficehoursnnAfterlecturestimeo
Griggs - ECON - 110
IntroductiontoComputerSpotlight1:EthicsbyDr.NguyenMinhHoangSaigonICT,HVUhoang.dhbk@gmail.com2010@byDr.NguyenMinhHoang,SaigonICT,HVU,20101ComputersAreYourFutureTenthEditionSpotlight1:EthicsCopyright 2009 Pearson Education, Inc. Publishing as Pr
Griggs - ECON - 110
NHNG NN VN MINH MT CHU M 1NGUYN NGC THChu M c phn cn li cath gii bit n t th k 15 caTy lch, c gi l Tn th gii.Tuy nhin, chu M thc cht khngh l chu lc mi v trong lch svng t ny tng c rt nhiu nnvn minh hnh thnh, pht trin huyhong ri sp trc khi ngichu u