2. (a) A student has been asked to put some parcels on a shelf. The parcels...
No answer yet for this question.
Ask a Tutor
Question:
Transcribed Image Text:
2. (a) A student has been asked to put some parcels on a shelf. The parcels all weigh different amounts, and the shelf has a maximum safe loading weight capacity of 100 Kg. The weight of parcels are as follows (in Kg): parcel 1 2 3 4 5 6 7 weight (Kg) 10 5 2 42 50 25 1 The student has been asked to load the maximum weight possible parcels on the shelf subject to the maximum safe loading weight. State two possible approaches for a greedy algorithm solution to solve this problem. In each case, state clearly the result you would get from applying that approach to this problem, stating whether the solution is optimal or not. If your answer does not produce an optimal solution, what algorithm could be employed to find one? [10 marks] (b) One example of a greedy algorithm is the Kruskal algorithm for finding a Minimum Spanning Tree. The algorithm is shown below. Kruskal(G,w) Let Q be the edges in E order ordered by increasing weight Initialise E to the empty set For each vertex v EV Let C(v) be the singleton set containing v While |E'| Consider the graph below with a set V of 8 vertices and a set of weighted edges E: V 10 V1 A A 12 V 3 Vz B B V3 6 18 V3 C C V4 15 SOO VA D D 19 14 6 V5 At the outset, each graph vertex is assigned to its own cluster, so each cluster is distinct and has exactly one element. So initially vertex V, is assigned to cluster A, to cluster B and so on. 20 Complete the table below showing which vertices belong to which clusters at each point in the algorithm where clusters are joined. You should assume that when a union of two clusters is formed, the new cluster takes the earliest letter applicable. For example, if cluster F = {v} ie. C(v) = F, and cluster G = (v) i.e. C(v) = G, then the union of clusters F and G would become cluster F= (v.7) and thus C (16) = F and C(v) = F. This is shown in the second row completed below. V5 E E V6 2 26 F 7 LL V7 F 8 4 V8 V7 G F I IS H [10 marks] (c) A message of length x symbols is made from a set of 8 symbols drawn from a vocabulary shown below, with each symbol being coded using 3 binary bits: 3-bit coding Symbol element (ii) A B C D E F G H 0 0 0 0 1 1 1 1 0 0 1 1 0 0 1 1 0 1 0 1 0 1 0 1 T(3) c when the size of A is 3 T(m) = T(m-3) + c otherwise Relative frequency So, the message BADGE (x = 5) would be coded as 001, 000, 011, 110,100. This message requires a constant 3 bits/symbol. Analysis shows that in general usage, the symbols appear with the relative frequency as shown also in the table. (1) 0.2 0.06 0.05 0.08 0.3 0.12 0.04 0.15 Construct a Huffman coding tree to determine the most efficient alternative coding for the symbols so as to minimise the number of bits/symbol to code a message. [10 marks] Determine the average number of bits/symbol required to code a message using this more efficient alternative coding. [5 marks] (d) A recursive algorithm is applied to some data A = (a,.....am) where m 2 3 and m is divisible by 3. The running time T is characterised using the following recurrence equations: Determine the running time complexity of this algorithm. Note that mis divisible by 3 and the problem size reduces by 3 for each recursion. [10 marks] (e) A student wishes to solve the Minimum Spanning Tree problem using a new algorithm they have devised. They decide to test their new algorithm against the well-known Kruskal and Prim algorithms. Discuss whether the new algorithm is guaranteed to produce an identical tree output as the Kruskal algorithm when provided with the same input graph. (5 marks] 2. (a) A student has been asked to put some parcels on a shelf. The parcels all weigh different amounts, and the shelf has a maximum safe loading weight capacity of 100 Kg. The weight of parcels are as follows (in Kg): parcel 1 2 3 4 5 6 7 weight (Kg) 10 5 2 42 50 25 1 The student has been asked to load the maximum weight possible parcels on the shelf subject to the maximum safe loading weight. State two possible approaches for a greedy algorithm solution to solve this problem. In each case, state clearly the result you would get from applying that approach to this problem, stating whether the solution is optimal or not. If your answer does not produce an optimal solution, what algorithm could be employed to find one? [10 marks] (b) One example of a greedy algorithm is the Kruskal algorithm for finding a Minimum Spanning Tree. The algorithm is shown below. Kruskal(G,w) Let Q be the edges in E order ordered by increasing weight Initialise E to the empty set For each vertex v EV Let C(v) be the singleton set containing v While |E'| Consider the graph below with a set V of 8 vertices and a set of weighted edges E: V 10 V1 A A 12 V 3 Vz B B V3 6 18 V3 C C V4 15 SOO VA D D 19 14 6 V5 At the outset, each graph vertex is assigned to its own cluster, so each cluster is distinct and has exactly one element. So initially vertex V, is assigned to cluster A, to cluster B and so on. 20 Complete the table below showing which vertices belong to which clusters at each point in the algorithm where clusters are joined. You should assume that when a union of two clusters is formed, the new cluster takes the earliest letter applicable. For example, if cluster F = {v} ie. C(v) = F, and cluster G = (v) i.e. C(v) = G, then the union of clusters F and G would become cluster F= (v.7) and thus C (16) = F and C(v) = F. This is shown in the second row completed below. V5 E E V6 2 26 F 7 LL V7 F 8 4 V8 V7 G F I IS H [10 marks] (c) A message of length x symbols is made from a set of 8 symbols drawn from a vocabulary shown below, with each symbol being coded using 3 binary bits: 3-bit coding Symbol element (ii) A B C D E F G H 0 0 0 0 1 1 1 1 0 0 1 1 0 0 1 1 0 1 0 1 0 1 0 1 T(3) c when the size of A is 3 T(m) = T(m-3) + c otherwise Relative frequency So, the message BADGE (x = 5) would be coded as 001, 000, 011, 110,100. This message requires a constant 3 bits/symbol. Analysis shows that in general usage, the symbols appear with the relative frequency as shown also in the table. (1) 0.2 0.06 0.05 0.08 0.3 0.12 0.04 0.15 Construct a Huffman coding tree to determine the most efficient alternative coding for the symbols so as to minimise the number of bits/symbol to code a message. [10 marks] Determine the average number of bits/symbol required to code a message using this more efficient alternative coding. [5 marks] (d) A recursive algorithm is applied to some data A = (a,.....am) where m 2 3 and m is divisible by 3. The running time T is characterised using the following recurrence equations: Determine the running time complexity of this algorithm. Note that mis divisible by 3 and the problem size reduces by 3 for each recursion. [10 marks] (e) A student wishes to solve the Minimum Spanning Tree problem using a new algorithm they have devised. They decide to test their new algorithm against the well-known Kruskal and Prim algorithms. Discuss whether the new algorithm is guaranteed to produce an identical tree output as the Kruskal algorithm when provided with the same input graph. (5 marks]
Expert Answer:
Related Book For
Modern Advanced Accounting In Canada
ISBN: 9781259066481
7th Edition
Authors: Hilton Murray, Herauf Darrell
Posted Date:
Students also viewed these algorithms questions
-
1. (40%) Suppose that the consumer in a continuous-time life-cycle model chooses the consumption path and retirement age to maximize R e-In (e(x)) dr - e-podz, subject to the equation of motion a(z)...
-
A registered dealer, based in Chandigarh, makes a supply to another registered dealer located in Chandigarh, valuing rupees 1,20,000. The applicable rate of GST is 12%. Calculate the amount of tax...
-
A 500 mm diameter closed-end steel pipe pile is to be driven to a depth of 17 m into the following soil profile. Depth (m) 0-2.0 2.0-6.5 6.5 16.0 16.0 17.5 Soil Classification Silty sand Fine to...
-
A 0.500-kg block, attached to a spring with length 0.60 m and force constant 40.0 N/m, is at rest with the back of the block at point A on a frictionless, horizontal air table (Fig. 7.44). The mass...
-
A vertical capillary is brought in contact with the water surface. What amount of heat is liberated while the water rises along the capillary? The wetting is assumed to be complete, the surface...
-
Mark Zuckerberg, is the owner of a well-known audio systems manufacturer. He wants to create a portfolio of suppliers for some of the electronics used in production. Based on historical data and...
-
What is products liability? Describe what legal theories an injured party can pursue when filing a lawsuit against a seller, manufacturer, or supplier of goods. Describe the defenses often used in...
-
A rookie quarterback is negotiating his first NFL contract. His opportunity cost is 10%. He has been offered three possible 4-year contracts. Payments are guaranteed, and they would be made at the...
-
2. If all n elements in the input array are the same, what is the big O notation of Insertion Sort? Why? (20 points) INSERTION-SORT(A) 1 for 2 to A.length key=A[j] //Insert A[] into the sorted 2 3...
-
The statement of cash flows for Riker Company (prepared using the indirect method) follows. Consider the following additional information: (a) Sales for the year totaled $812,350. Cost of goods sold...
-
Charlies Chocolates stockholders made investments of $50,000 and received dividends of $20,000. The company has revenues of $83,000 and expenses of $64,000. Calculate its net income.
-
Bugattis return on equity is 15 percent, and the management plans to retain 50 percent of earnings for investment purposes. What will be the firms growth rate?
-
Define the term cost of capital.
-
Bestattung Wiens preferred stock is selling for \($43.29\) per share and pays \($2.10\) in dividends. What is your expected rate of return if you purchase the security at market price?
-
In early 2018, the Alfa Corporation issued new common stock at a market price of \($30.\) Dividends last year were \($2\) and are expected to grow at an annual rate of 3 percent forever. Flotation...
-
You are planning to purchase 200 shares of preferred stock and must choose between the preferred shares of Compagnie Maritime Belge (CMB) or Delhaize Le Lion. CMBs stock pays an annual dividend of...
-
Hai wanted to become a taxi driver in New Westminster. Thedifficulty for him was that the city of New Westminster only allowsa certain number of taxis. To become a taxi driver, he needed buyboth a...
-
A bar of length = 1 has one fixed and one free end and stiffness function c(x) = 1 - x. Find the displacement when subjected to a unit force. Pay careful attention to the boundary condition at the...
-
You have been recently elected to the position of treasurer on the board of directors for Canoes Are Us, a community-based service and NFPO that provides canoeing lessons and canoe rentals to various...
-
On December 31, Year 2, Palm Inc. purchased 80% of the outstanding ordinary shares of Storm Company for $310,000. At that date, Storm had ordinary shares of $200,000 and retained earnings of $60,000....
-
On January 1, Year 3, Jets Ltd., a Winnipeg-based private company, purchased 80% of the shares of Buenos Inc. for 1,900,000 Argentine pesos (AP)-an amount which, at that date, translated to $655,172....
-
You have two regions, A and B, of differently doped silicon, with the regions joined together to make a continuous silicon crystal. When the positive terminal of a battery is connected to region...
-
In Figure P32.33, what combinations of positive bias (input signals) A, B, C, D allow the light bulb to light up? Data from Figure P32.33 A B OR JOR AND D
-
Suppose a transistor consists of a very narrow \(p\)-type material sandwiched between two very wide regions of \(n\)-type material. (a) Is the charge on the \(p\)-type region positive or negative,...
Study smarter with the SolutionInn App