You are on page 1of 2
en B 1. What is the smallest integer n such that f(x) is O(a") where f(x) = (a + 1)(# + 2)a+ ’ Oxted 4 OMS) iy ann » Math 230 (Ellis) Spring 2008 Quiz 2 (c) 3 * ae (a) 1 a \H 2. Find witnesses C and é that demonstrate that f(z) = 32% + Saris O(a). (Hint: > k IF@) Cla?) Let (Bol) Than 3x45 4 Behe Ske BX", and evatning, 1S eoschwe. so let [C=8. (Fer |, (22eSel 4 SAL Shel = 3x2 2 Bx* = FPS 3. Which of these statements is true? (a) IF f is O(g), then g is O(f). (b)_Iff is O(g), # (e)_If fis O(g), then f is O(/3.> (a) If; and fo are O(G), then fifa is O(g). 4, The bubble sort algorithm is as follows. procedure bubblesori(ai,...,ay: real numbers with n > 2) for i:=1ton—1 for j:=1ton-1 if a; > aj41 then interchange aj and o541 {a1,...,49 is in increasing order } If the input list is 4,2,1,9, give the list after the for loop completes each value of i before soe io | 3 attr i=L: ele ~~ at 43 ze yl after (=2% 123 after i=3: plz e4 5. A cashier using a strange currency system has coins worth 7, 5, and 1 cents. Give a value for which the greedy way of making change gives a larger number of coins than the optimal way of making change. Write down both ways of making change. labeling one “greedy” and the other “optimal” i= Be 1 dsideid Grady sd+s¢ Cophine t) Nes F¢+4-id of =asetid Co) 6. For the bubble sort algorithm (written elsewhere in this quiz), write down the average ease time complexity and the worst case time complexity using the notation @(f(n)) for the appropriate function f(n). (There will be two answers, clearly label them "average case” and “worst case”) Rywndae Case = Bn?) Lowrct case = On) Cuno Coumtg. Companisoas za other fey foo Sepknechor , PMA (Public Mathematics Announcement) 12:50-1:40pm - Math Club with Professor Trefethen, Life Sciences Building, Room 111 (lunch provided!) 3:15-5:30pm Menger Day talks in MeCloska Ballroom, MTCC

You might also like