h3_6a
15 Pages

h3_6a

Course Number: PHYS PHYS 6a, Spring 2009

College/University: UCSB

Word Count: 2255

Rating:

Document Preview

Homework Assignment 3 Solutions Problem 2.33: Air-bag injuries. During an auto accident, the vehicle's air bags deploy and slow down the passengers more gently than if they had hit the windshield or steering wheel. According to safety standards, the bags produce a maximum acceleration of 60 g, but lasting for only 36 ms (or less). How far (in meters) does a person travel in coming to a complete stop in 36 ms at a...

Unformatted Document Excerpt
Coursehero >> California >> UCSB >> PHYS PHYS 6a

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.

Assignment Homework 3 Solutions Problem 2.33: Air-bag injuries. During an auto accident, the vehicle's air bags deploy and slow down the passengers more gently than if they had hit the windshield or steering wheel. According to safety standards, the bags produce a maximum acceleration of 60 g, but lasting for only 36 ms (or less). How far (in meters) does a person travel in coming to a complete stop in 36 ms at a constant acceleration of 60g? Answer: 38.1 cm Before we try to solve this problem, convert 36 ms into seconds: 1 sec 36 ms =0.036 sec 1000 ms Then we need to use two kinematic equations. First we use v =v o at to find the initial velocity v o (or velocity before the braking started). We assume v = 0 (because it stops): v o=at v o =609.8 m / s 20.036 s v o= 21.2 m / s Note that the acceleration is negative (i.e., a deceleration). Then, we use the second kinematic equation, 2 2 v =v o 2a x , to find the distance x traveled in 0.036 sec (remember v = 0 because it stops): v x= o 2a 21.2 m / s 2 x= 2 60 9.8 m / s 2 x = 0.381 m x =38.1 cm 2 Problem 2.38 The "reaction time" of the average automobile driver is about 0.700 s. (The reaction time is the interval between the perception of a signal to stop and the application of the brakes.) If an automobile can slow down with an acceleration of 12.0 ft / s 2 , compute the total distance covered in coming to a stop after a signal is observed (a) from an initial velocity of 15.0 mi/h (in a school zone) and (b) from an initial velocity of 55.0 mi/h. A) Answer: 10.8 m First, convert 12.0 ft / s 2 into m/s: 12 ft 1 meter 2 =3.7 m / s 2 1 s 3.28 ft And convert 15.0 mi/h into m/s: 15.0 mi 1609 meters 1 hr = 6.7 m / s 1 hr 1 mi 3600 sec Then to solve, we need to break the problem into two parts. The first part is when the car is not braking due to the fact that the driver has a reaction time. This distance d 1 , is easy to calculate: d 1= v o t d 1=6.7 m / s 0.7 s d 1= 4.69 m Then we need to use the kinematic equation v =v o 2a x to find the second distance d 2 . In this equation, x is our d 2 and v = 0 . v 2 o 2a 6.7m / s 2 d 2= 2 3.7 m / s 2 d 2=6.1 m d 2= Finally, we get d total by adding up d 1 and d 2 : d total =d 1d 2 d total =10.8 m 2 2 B) 99.9 m First convert 55.0 m/h into m/s: 55.0 mi 1609 meters 1 hr =24.6 m / s 1 hr 1 mi 3600 sec Then we solve it the same way that we solved A: d 1= v o t d 1= 24.6 m / s 0.7 s d 1=17.2 m v o 2a 24.6 m / s 2 d 2= 2 3.7 m / s 2 d 2=81.8 m d 2= d total = d 1 d 2 d total =99.9 m 2 Problem 2.73 It has been suggested, and not facetiously, that life might have originated on Mars and been carried to Earth when a meteor hit Mars and blasted pieces of rock (perhaps containing primitive life) free of the surface. Astronomers know that many Martian rocks have come to Earth this way. (For information on one of these, search the Internet for ALH 84001.) One objection to this idea is that microbes would have to undergo an enormous, lethal acceleration during the impact. Let us investigate how large such an acceleration might be. To escape Mars, rock fragments would have to reach its escape velocity of 5.0 km/s, and this would most likely happen over a distance of about 4.0 m during the impact. A) What would be the acceleration, in m/s2, of such a rock fragment? Answer: 3.1310 6 m / s2 First convert, 5.0 km/s into m/s: 5.0 km 1000 m =5000 m / s 1 sec 1 km To find the acceleration, use: v =v o 2a x Where v =0 m / s , v o=5000 m / s , and x = 4.0 m : v2 o 2 x 5000 m / s 2 a= 2 4.0 m a =3.1310 6 m / s 2 a= B) What would be the acceleration, in g's, of such a rock fragment? Answer: 3.1910 5 g ' s Just divide the answer in A by 9.8 m / s 2 : 3.1310 m / s =3.19 105 g ' s 2 9.8 m / s 6 2 2 2 C) How long would this acceleration last? Answer: 1.60 ms Use the following kinematic: Set v = 0 and solve for t (and convert to ms): v o a 5000 m / s t= 3.13 106 m / s 2 t =1.60 103 s t =1.60 ms t= D) In tests, scientists have found that over 40% of Bacillius subtilis bacteria survived after an acceleration of 450000g. In light of your answer to part A, can we rule out the hypothesis that life might have been blasted from Mars to Earth? Answer: No. v =v o at Problem 2.72: Prevention of hip fractures. Falls resulting in hip fractures are a major cause of injury and even death to the elderly. Typically, the hips speed at impact is about 2.0 m/s. If this can be reduced to 1.3 m/s or less, the hip will usually not fracture. One way to do this is by wearing elastic hip pads. A) If a typical pad is 5.0 cm thick and compresses by 2.0 cm during the impact of a fall, what acceleration (in m/s2) does the hip undergo to reduce its speed to 1.3 m/s? Answer: 57.8 m / s 2 First convert everything to m: 5 cm=0.05 m , 2.0 cm =0.02 m Now, use the following kinematic equation and solve for a: v =v o 2a x 2 2 Here, v o= 2.0 m / s , v =1.3 m / s and x =0.02 m : v 2 v 2 o 2 x 1.3 m / s 2 2.0 m / s 2 a= 2 0.02m a=57.8 m / s 2 a= B) What acceleration (in g's ) does the hip undergo to reduce its speed to 1.3 m/s? Answer: 5.89 g's Just divide A by 9.8 m / s 2 : a= 57.8 m / s 2 2 9.8 m/ s a=5.89 g ' s C) The acceleration you found in part A may seem like a rather large acceleration, but to fully assess its effects on the hip, calculate how long it lasts. Answer: 1.21102 sec Just use: and solve for t: v = v oat v v 0 a 2.0 m/ s 1.3 m / s t= 57.8 m / s 2 t =1.21 102 sec t= Problem 2.58: Physiological effects of large acceleration. The rocketdriven sled Sonic Wind No. 2, used for investigating the physiological effects of large accelerations, runs on a straight, level track that is 1080 m long. Starting rest, from it can reach a speed of 1610 km/h in 1.80 s. A) Compute the acceleration in m/s2. Answer: 248 m / s2 First, convert the speed into m/s: 1610 km 1 hour 1000 m = 447.2 m/ s 1 hour 3600 sec 1 km Now use the equation: v =v o at Where v = 447.2 m / s , v o= 0 m / s , and t =1.8 s . Solve for a: v vo t 447.2 m / s a= 1.8 s a = 248 m / s 2 a= B) Compute the acceleration in gs. Answer: 25.3 g's Again, divide A by 9.8 m / s 2 : a= 248 m / s 2 9.8 m/ s 2 a= 25.3 g ' s C) What is the distance covered in 1.80 s? Answer: 403 m To find x use: 12 x = x o v o t a t 2 And set v o =0 m / s , t =1.8 s , and a =248 m / s 2 : 1 2 2 x = 248 m / s 1.8 s 2 x =403 m D) A magazine article states that, at the end of a certain run, the speed of the sled decreased from 1020 km/h to zero in 1.40 s and that, during this time, its passenger was subjected to more than 40g. Are these figures consistent? Answer: No. Tossing Balls off a Cliff Learning Goal: To clarify the distinction between speed and velocity, and to review qualitatively onedimensional kinematics.A woman stands at the edge of a cliff, holding one ball in each hand. At time t 0 , she throws one ball straight up with speed v 0 and the other straight down, also with speed v 0 . For the following questions neglect air resistance. Pay particular attention to whether the answer involves absolute quantities that have only magnitude (e.g., speed) or quantities that can have either sign (e.g., velocity). Take upward to be the positive direction. A) If the ball that is thrown downward has an acceleration of magnitude a at the instant of its release (i.e., when there is no longer any force on the ball due to the woman's hand), what is the relationship between a and g, the magnitude of the acceleration of gravity? a) a > g b) a = g c) a < g Register to View AnswerThe only acceleration that is acting on the ball once it is released is an acceleration due to gravity. B) Which ball has the greater acceleration at the instant of release? a) the ball thrown upward b) the ball thrown downward c) Neither; the accelerations of both balls are the same. Register to View AnswerAgain, the only acceleration acting on either ball is that due to gravity. They both feel the same amount of acceleration due to gravity. C) Which ball has the greater speed at the instant of release? a) the ball thrown upward b) the ball thrown downward c) Neither; the speeds are the same. Register to View AnswerThough the ball thrown upward has an upward, positive velocity and the ball thrown downward has a downward, negative velocity, their speeds (or magnitudes of velocity) are the same. D) Which ball has the greater average speed during the 1-s interval after release (assuming neither hits the ground during that time)? a) the ball thrown upward b) the ball thrown downward c) Neither; the speeds are the same. Register to View AnswerThe ball thrown down will accelerate while the ball thrown upward will first slow down. E) Which ball hits the ground with greater speed? a) the ball thrown upward b) the ball thrown downward c) Neither; the balls hit the ground with the same speed. Register to View AnswerEven though in D, the ball thrown downward has a larger velocity 1-s after release, they both hit the ground with the same speed. However, the ball thrown upward will hit the ground after the ball thrown downward. Rocket Height A rocket, initially at rest on the ground, accelerates straight upward from rest with constant acceleration 39.2 m / s 2 . The acceleration period lasts for time 6.00 s until the fuel is exhausted. After that, the rocket is in free fall. A) Find the maximum height y max reached by the rocket. Ignore air resistance and assume a constant acceleration due to gravity equal to 9.8 m/s2. Answer: 3530 m This problem has two stages. For the first stage, which lasts 6.00 s, the rocket experiences an acceleration of: a 1=39.2 m / s 2 In the second stage, the acceleration is: a 2=9.8 m / s 2 The total height will be a sum of the distance traveled in either stage: h =h 1 h2 So now, to find h1 : 12 h 1= v o t a 1 t 2 where v o= 0 m / s , a1=39.2 m / s2 , and t =6.00 s : 1 h 1= 39.2 m / s 2 6.00 s 2 2 h1=706 m And to find h 2 , we use the kinematic equation: v =v o 2a x where x = h2 , a =a 2 , v = 0 m / s (at final height), and v_o is the final velocity from first stage. To find v o : v =v o at v = 39.2 m / s 2 6.00 s v =235.2 m / s (from first stage) 2 2 Now we are ready to find h 2 : 2 v o 2 a2 235.2 m / s 2 h 2= 2 9.8 m / s 2 h2= 2824 m h 2= So now, to find h, just add up h1 and h 2 : h= h1h 2 h =706 m2824 m h= 3530 m Problem 2.57 A rock is thrown vertically upward with a speed of 12.0 m/s from the roof of a building that is 60.0 m above the ground. Assume free fall. A) In how many seconds after being thrown does the rock strike the ground? Answer: 4.93 s Draw a picture: vo 60.0 m To solve this problem efficiently, we should use the equation: 12 x = xo v o t a t 2 Here, x x o=60.0 m , v o=12 m/ s and a =9.8 m/ s 2 . We know everything except t. This means that to solve this equation, we'll need to solve a quadratic. Before we plug numbers in, lets put it into the standard form for the quadratic formula: 12 a t v o t x x o= 0 2 From this, we can plug it into our quadratic formula: 1 v o v 2 4 a x x o o 2 t= 1 2 a 2 2 12 m / s 12 m / s 2 9.8 m / s 2 60.0m t= 9.8 m/ s 2 t =1.22 s 3.71 s t =4.93 s or 2.49 s We can see from the calculations that the only possible answer is 4.93 s. B) What is the speed of the rock just before it strikes the ground? Answer: 36.3 m/s To answer this, we can use: v 2 = v 2 2 a x o 2 v = vo 2 a x v = 12 m / s 22 9.8 m / s2 60.0 m v =36.3 m / s

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:

UCSB - PHYS - PHYS 6a
UCSB - PHYS - PHYS 6a
UCSB - PHYS - PHYS 6a
UCSB - PHYS - PHYS 6a
UCSB - PHYS - PHYS 6a
UCSB - PHYS - PHYS 6a
UCSB - PHYS - PHYS 6a
Problem 1) a) W=| F| | s| cos() and =90 so W=0 b) 0&lt;90 and so cos()&gt;0 so that W&gt;0 c) Here =-180 so W&lt;0 d) =0 so W&gt;0 e) W&lt; 0 f) =-90 so W=0 g) cos()&gt;0 for 0&gt; -90 h) a. | s|=160m , | F| =18N, =0 so W=2900J b. | F| =30N, =30 so W=4200J c. | F| =12N, =-180 so
UCSB - PHYS - PHYS 6a
Problem 7.2 In the rough area, the block decelerates and travels a distance s. We can use the equation vf2= vi2+2ax. When x =s, vf=0. We can solve for acceleration: a=-vi2/2s. We want to find the distance traveled when vf= vi/3. Using vf2= vi2+2ax, we get
UCSB - PHYS - PHYS 6a
Problem 1) a) F=ma and the force supplied by both engines is the same. Therefore car b will have a greater acceleration and hence greater velocity 1 m into the race. b) We know work is change in kinetic energy. Also, W=force*distance. The same amount of w
UCSB - PHYS - PHYS 6a
UCSB - MCDB - mcbd 1A
ENZYME ACTION: EXPERIMENTS WITH TYROSINASESECOND LABORATORYPre-lab Write-Up, Week 2: The pre-lab write-up for the Enzyme Action lab (second experiment) should consist of a table that will act as an outline (i.e., protocol) for the experiment that you wi
UCSB - MCDB - mcbd 1A
EXERCISE8PLANT GENETICS V COMPUTER GENETICS (DROSOPHILA) SEX LINKAGE AND HUMAN GENETICSEquipment and supplies needed:Computers F2 Seedlings Forceps Paper TowelsPART I: Observation and Analysis of Brassica SeedlingsThe purpose of this exercise is to
Harvard - ECON - 1010
WELCOME TO ECONOMICS E-1010: WELCOME TO ECONOMICSMICROECONOMIC THEORYFall 2008 W, 7:35-9:35 Sever 213 Robert Neugeboren 51 Brattle St, Rm 522 W 3-4 and by appt. rshankar@fas.harvard.edu neugebor@fas.harvard.edu TA: Rajiv ShankarSections: Tu 6:30-7:30 o
Harvard - ECON - 1010
UNIT I: Theory of the Consumer Introduction: What is Microeconomics? Theory of the Consumer Individual &amp; Market Demand9/24Theory of the Consumer Preferences How do consumers make Indifference Curves optimal choices? Utility Functions Optimization How
Harvard - ECON - 1010
UNIT I: Theory of the Consumer Introduction: What is Microeconomics? Theory of the Consumer Individual &amp; Market Demand10/1Individual &amp; Market Demand Income &amp; Substitution Effects Normal, Inferior, and Giffen Goods Consumer Demand The Determinants of D
Harvard - ECON - 1010
UNIT II:10/8FIRMS &amp; MARKETS Theory of the Firm Profit Maximization Perfect Competition Review 11/5 MIDTERMTheory of the FirmToday we will build a model of the firm, based on the model of the consumer we developed in UNIT I. Where consumers attempt t
Harvard - ECON - 1010
UNIT II: FIRMS &amp; MARKETS10/15Theory of the Firm Profit Maximization Perfect Competition Review 11/5 MIDTERMProfit Maximization Last Time The Long-Run and the Short-Run Firm and Market Supply Perfect Competition (Part 1)Last TimeWe saw last time th
Harvard - ECON - 1010
UNIT II: Firms &amp; Markets10/22Theory of the Firm Profit Maximization Perfect Competition Review 11/5 MIDTERMPerfect CompetitionIs it true that the rational pursuit of private interests produces coherence rather than chaos, and if so, how is it done?
Pittsburgh - IE - IE 2101
How to Choose a Warehouse Management SystemHow to Choose a Warehouse Management SystemWhen it comes to choosing the right warehouse management system (WMS) for your business, its important to understand your warehouse needs and the benefits of having an
Washington - CS - 100
/* * Compilation: javac HuffmanEncoder.java In.java * Execution: java HuffmanEncoder.java &lt; input.txt * * Read in a list of 8-bit extended ASCII characters and output * their Huffman encoding. * * * % java HuffmanEncoder &lt; abra.txt * * */ public class Huf
Washington - CS - 100
/* HW4 - HuffmanTree.java Junghyun Kim ole2000@cs.uoregon.edu http:/www.cs.uoregon.edu/~ole2000 * */ p package ole2000; public class HuffmanTree cfw_ protected Object data; protected int freq; protected String prefix; protected HuffmanTree parent; protect
Cincinnati - ECON - 101
Principles of Microeconomics Chapter 101.Economic cost can best be defined as:Review QuestionsA) any contractual obligation that results in a flow of money expenditures from an enterprise to resource suppliers. B) any contractual obligation to labor or
McMaster - CAS - 2c03
SOLUTIONS TO THE MIDTERM TEST 1.[10] a.[5] 6n3/(log n + 1) = O(n3) Let c=7, n0=2. For all n 2, log n 1, and log n +1 2 Then, 6n3/(log n +1) 6n3/2 = 3n3 7n3 hold. 10n3 +9 = O(n). We have to find such n (not necessarily the smallest one) that for every n n
McMaster - CAS - 2c03
q:=p+1; while q&lt;&gt;(L.last +1) do if L.elements[q]= L.elements[p] then while q&lt;&gt;(L.last +1) do begin L.elements[q]:= L.elements[q+1] L.last:=L.last-1 end else q:= q+1 p:=p+1 end end(1)O(n2). It looks like 3 nested loops, so O(n3). By more careful investig
McMaster - CAS - 2c03
5.[13] a.[10] type Tree = record labels: array[1.max] of labeltype; n: 1.max; end; procedure Preorder(T: Tree) begin PrintPre(T, 1) end procedure PrintPre(T:Tree, m:1.max) begin if m&gt;T.n then return; write(T.lables[m]); PrintPre(T, 2*m); PrintPre(T, 2*m+1
McMaster - CAS - 2c03
CS2MD3-SOLUTIONS TO THE MIDTERM TEST Summer 2001 1.[20] a.[10] 8pts: procedure DUP(L); var x:^node; temp:^node; begin X:=L; while X^.next&lt;&gt;nil do begin new(temp); x:=x^.next; temp^.element:=x^.element; temp^.next:=x^.next; x^.next:=temp; x:=x^.next; cfw_
McMaster - CAS - 2c03
2.[10] The solution is not unique, for instance the symmetric one is also o.k.1a0.50.30.2 ebcda = 0, b=100, c=101, d=110, e=111 average = 0.51 + 0.153 + 0.153 + 0.13 + 0.13 = 2.03.[10] function SUBSET(A,B:SET):boolean; var p,q:^celltype; begin p
McMaster - CAS - 2c03
4.[10] Final solution (without all the steps)9583467125.[10] a.[4]BFS: 11,12,3,4,5,7,14,15,10,1,2,13,8,9,16 DFS: 11,12,7,8,14,3,15,9,4,10,1,16 preorder: 11,12,7,8,14,3,15,9,4,10,1,16,17,2,5,13 postorder: 8,7,12,14,9,15,3,10,16,17,1,2,4,13,5,1 i
McMaster - CAS - 2c03
SOLUTIONS TO THE MIDTERM TEST 1.[7] function PREVIOUS(p, L) : position; var q : position; begin q := FIRST(L); while qgEND(L) cfw_ or qgnil do if NEXT(q,L) = p then return(q) else q:=NEXT(q); write(invalid position) end; More informal description is Engl
McMaster - CAS - 2c03
4.[15] a.[5]For instanceabcdelast b.[10] The simplest is the recursive procedure: global var T : record nodes : array[1.max] of nodes; last : 0.max end; procedure INORDER(i : 1.max); begin if 2i T.last then INORDER(2i); print (T.nodes[i]); if 2i +
McMaster - CAS - 2c03
always full, and that height(T1)=height(T)-1, height(T2)height(T)-1. Note also that if T1 is not full than height(T2)=height(T)-2. Thus, in this case we have, height(T1)=3-1=2. If T1 is full then the height 2 implies T1 has 4 leafs at the bottom level. Si
McMaster - CAS - 2c03
8342719656.[10] a.[4]BFS: 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16 DFS: 1,2,7,14,8,3,9,15,4,10,11,16 preorder: 1,2,7,14,8,3,9,15,4,10,11,16,17,12,5,13 postorder: 14,7,2,8,15,9,3,10,16,17,11,12,4,13,5,1 inorder: 14,7,2,8,1,15,9,3,10,4,16,17,11,12,1
McMaster - CAS - 2c03
SOLUTIONS TO THE MIDTERM TEST1.[20] a) possible solutions:solution 1 procedure REMOVEALL(x:element, var L:LIST) var q:position; flag:integer begin flag=0; q:=L; while q^.next&lt;&gt;nil begin if q^.next^.element=x then if flag=0 then begin flag:=1; q:=q^.next
McMaster - CAS - 2c03
if (x=L.elements[i]) then for j:=i+1 to L.last do begin L.elements[j-1]:=L.elements[j]; L.last:=L.last-1; end i:=i+1; end end O(n*n) Solution 2type LIST = record elements: array[1.maxlength] of elementtype; last: integer end; position = integer; prodedur
McMaster - CAS - 2c03
solution 2The average code length is 0.08 3+0.123+0.23+0.23+0.41=2.23.[15]a)1234 abaa f(i) 0 0 1 1 g(i) 0 1 1 2b)5 b 2 26 a 3 3 not needed for (a).solution type1 (general) First note that if n=1 then mn = m &lt; m+1 = m+n, so an algorithm with comple
McMaster - CAS - 2c03
BFS means layer by layer starting from the top, i.e. (layer 1) 1 (layer 2) 2 3 (layer 3) 4 5 6 7 DFS means going to leaf starting from the left and than going back to parents and then to unvisited children, in general going around the tree anticlockwise,
McMaster - CAS - 2c03
else begin z:=x mod y; if z=0 then gcd:=y else begin push(x,y,1),S); goto 0; end end 1: if not empty(S) then (x,y,1) := top (S); pop(S); goto 1; end6.[10] Construct the string C=AA. Then B is a cyclic shift of A if and only if B is a substring of C. To c
McMaster - CAS - 2c03
Solutions to the Midterm Test 1. a. b. c. f(n) = O(n3), g(n)=O(nlogn). Note, log5n =log5 +logn =O(logn) f(n)+g(n) = O(max(f(n), g(n) =O(n3) f(n)g(n) =O(n4logn), since n3*nlogn= n4logn2. a. O(|A|B|), we have to compare each element of one set with each el
McMaster - CAS - 2c03
b. Yes. For instance c(a) = 0, c(b) = 1, c(c) = 00, c(d) = 01, c(e)=10. Then the average length is 1.40. But the code does not have prefix property, and it is useless, because it results in ambiguity when decoding. 4. a. abbabb f(i) 0 0 0 1 2 3 g(i) 0 1 1
McMaster - CAS - 2c03
if DATA(v)=x then return(true); if LEFTMOST_CHILD(v,T)&lt;&gt; null then begin v:= LEFTMOST_CHILD(v,T); ENQUEUE(v,level); while RIGHT_SIBLING(v,T)&lt;&gt;null do begin v:=RIGHT_SIBLING(v,T); ENQUEUE(v,level); end end end return(false) end c. O(n). In worst case, all
McMaster - CAS - 2c03
SOLUTIONS TO THE MIDTERM TEST1. [15] function NEXT(p: position, L: list): position var q, BEGIN: positin; begin if EMPTY(L) then write(empty list); q:=PROVIOUS(FIRST(L), L); BEGIN:=q; while (PROVIOUS(q,L) &lt;&gt; BEGIN do if PROVIOUS(q,L) = p then return(q) e
McMaster - CAS - 2c03
b.[10] type List = record elements: array[1.maxlength] of elementtype; last: integer; end; procedure ERASE_DUPLICANTS(L: List); var p,q: integer; begin p:=1; while p&lt;&gt;(L.last + 1) do begin q:=p+1; while q&lt;&gt;(L.last +1) do if L.elements[q]= L.elements[p] th
McMaster - CAS - 2c03
Average code length 20.4 + 20.2 + 20.2 + 30.08 + 40.08 + 40.04 = 2.32 The optimal Hoffman code is not unique, however, the average length is unique. 4.[10] a. [6] Pat J F(j) b.[4] A 1 0 b 2 0 a 3 1 b 4 2 a 5 3 a 6 1Same for standard algorithm and KMP. Fo
McMaster - CAS - 2c03
So, the tree should be as, 1 2 3 4 56 7 9 8 104
McMaster - CAS - 2c03
Solutions to Midterm 1.[10] a.[5] Using only definition of O(f(n) prove that the following statement is true: 2n2/(log n + 1) = O(n2) b.[5] Using only definition of O(f(n) prove that the following statement is false: 2n2 +1 = O(n) a) We claim that 2n2/(lo
McMaster - CAS - 2c03
Suppose we are lucky and each time a pivot is such that the sublist to its left is of the same size as that to its right. This would leave us with the sorting of two sublists, each of size roughly n/2. Therefore we have: T(n) = 2T(n/2)+cn for some constan
McMaster - CAS - 2c03
b) 6 / 4 / 3 / 1 \ 7 \ 9After DELETEMIN: 6 /\ 4 7 / \ 3 9 5.[10] Here are eight integers: 8, 5, 9, 3, 2, 10. Sort them using: a.[2] insertion sort b.[5] QuickSort (choose pivot as in the textbook, not randomly) c.[3] merge sort ( non-recursive) Illustrat
McMaster - CAS - 2c03
c) 8, 5, 9, 3, 2, 10 5, 8, 3, 9, 2, 10 \/ | 3, 5, 8, 9, 2, 10 \ / 2, 3, 5, 8, 8, 10, 9Worst case and average case are O(n logn)6.[10] Suppose we are hashing integers with a hash table of length 5 using the hash function h(i)=i mod 5. a.[5] Show the resu
McMaster - CAS - 2c03
CS2MD3. Sample solutions to the assignment 1 (many questions have more than one solutions). Total for this assignment is 214 pts. The assignment is worth 5%. If you think your solution has been marked wrongly, write a short memo stating where marking in w
McMaster - CAS - 2c03
In principle it suffices to find such n than for every n n, g(n)&gt;Cf(n). Then clearly for every n &gt; max(n, n0&gt;0), the above formula hold. In practice finding n is considered as a solution. It does not need to be the smallest n such that g(n)&gt;Cf(n). a.[3] 1
McMaster - CAS - 2c03
n+1 &gt; Clogn. Clearly n+1 &gt; n, so it suffices to solve n &gt; Clogn. From the question 1d above we conclude that Clogn 2C n1/2. So all we need is to solve n &gt; 2Cn1/2, or equivalently n1/2 &gt; 4C2. This means n &gt; 4C2 implies n+1&gt;Clogn, for all C&gt;0. 3.[15] T1(n)=
McMaster - CAS - 2c03
b.[5]procedure P2(n:integer); var i,j,k : integer; begin for i:=1 to 100000000 do for j:=i-1 to 20*n do for k:=1 to j do cfw_some statement requiring O(1) time end T(n) = 100000000i=1T = 100000000i=1(20nj=i-1T) = 100000000i=1(20nj=i-1(jk=1O(1) = 10000000
McMaster - CAS - 2c03
T(n) = if n1 then C1 else C + T(n-1) +T(n div 2) Let T1(n) and T2(n) be the following functions: T1(n) = if n1 then C1 else C + 2T1 (n-1), T2(n) = if n1 then C1 else C + 2*T2 (n div 2). Clearly T2(n) &lt; T(n) &lt; T1 (n) if n&gt;1. Note that, for n &gt; 1: T1 (n) =
McMaster - CAS - 2c03
7.[55] Sort the following numbers using [5] bubble, [5] insertion, [5] bin, [5] Shell, [10] quick, [15] heap, and both [5] the recursive and [5] non-recursive versions of the 2-way merge sort: 5, 11, 20, 8, 13, 10, 25, 7, 30, 12, 10, 40, 0, 3, 10, 21, 16,
McMaster - CAS - 2c03
Pass16: 0, 3, 5, 7, 8, 10, 10, 10, 11, 12, 13, 16, 20, 21, 25, 30, 40, 74 Pass17: 0, 3, 5, 7, 8, 10, 10, 10, 11, 12, 13, 16, 20, 21, 25, 30, 40, 74 Bin: First pass: Bin:0 20 10 30 10 40 0 101 11 212 123 13 34 745 5 256 167 78 89The concatenated
McMaster - CAS - 2c03
5 incr=411 10 80310716 1220 40 1310 25 2130 740 incr=2310 7510 10813 1120 21 16 1225 4030 740 incr=1 0 quick:3 357 5710 88 10 10 1010 1013 11 11 1216 12 20 21 13 16 20 2125 40 25 3030 74 40 745 11 20 8 13 10 25 7 30 12 10 40
McMaster - CAS - 2c03
11 12 11 12result: 0, 3, 5, 7, 8, 10, 10, 10, 11, 12, 13, 16, 20, 21, 25, 30, 40, 74 heap: 5 insert(5) 5 insert(11) 11 insert(20) 11 20 11 5 insert(13) 8 11 13 20 11 insert(10) 8 10 11 13 20 5 insert(25) 8 5 insert(25) 10 7 13 20 25 5 10 5 insert(8) 8 20
McMaster - CAS - 2c03
0 insert(10) 7 8 10 10 3 511 30 13 12 40 20 25 10 0 insert(21) 7 8 10 10 3 5 11 21 8 30 16 13 insert(16) 7 10 10 25 3 5 10 011 30 13 12 40 20 25 10 2112 40 200 insert(74) 7 8 10 10 3 511 30 13 12 40 20 25 10 21 16 74 3 delete(0) 7 8 10 10 5 1011 30
McMaster - CAS - 2c03
5 delete(3) 7 8 10 16 10 10 11 21 10 30 13 delete(5) 8 167 10 10 12 40 20 25 7411 30 13 12 40 20 25 74 21 8 delete(7) 10 11 12 16 10 1010 delete(8) 11 21 25 30 13 12 16 10 1021 30 13 74 40 20 2574 40 2010 delete(10) 11 21 12 16 delete(10) 10 20 25 2
McMaster - CAS - 2c03
20 delete(16) 21 25 74 25 delete(21) 40 74 40 delete(30) 74 delete(40) 74 delete(25) 30 40 40 delete(20) 30 40 25 7421 3030 74delete(74)result: 0, 3, 5, 7, 8, 10, 10, 10, 11, 12, 13, 16, 20, 21, 25, 30, 40, 74 non-recursive 2-way merge: 5 5 5 5 0 0 11
McMaster - CAS - 2c03
8.[20]Write a program (in pseudo-code) to find the mode (the most frequently occurring element) of a list of elements. What is a complexity of your program?[10] 1. MODE(A) 2. 3. / A: array of elements 4. / F: frequency 5. SORT(A) 6. m 0 7. l 0 8. F(1) 1