Given a graph as in Fig. 1, we are interested in finding the shortest paths from...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Given a graph as in Fig. 1, we are interested in finding the shortest paths from the source a to all other vertices using the Dijkstra's algorithm and a min-heap as a priority queue. Note that a min-heap is the same as a max-heap, except that the key stored at a parent node is required to be smaller than or equal to the keys stored at its two child nodes. In the context of the Dijkstra's algorithm, a node in the min-heap tree has the format v(pv, dv), where d, is the length of the current shortest path from the source to v and p, is the second to last node along that part (right before v). For example, b(a, 4) is one such node. We treat d, as the key of Node u in the heap, where uela,b,c,d,e, f,g,h}. Source: 3 C 6 h Figure 1: An input graph for the Dijkstra's algorithm. Edge weights are given as integers next to the edges. For example, the weight of the edge (a, b) is 4. a) [1 mark] The min-heap after a(a,0) is removed is given in Fig. 2. The next node to be removed from the heap is b(a, 4). Draw the heap after b(a, 4) has been removed and the heap has been heapified (fixed), assuming that co2oo. No intermediate steps are required. c(a, 8) b(a, 4) d(a, 6) e(-,∞0) f(-∞) g(,00) h(-,∞0) Figure 2: The min-heap (priority queue) after a(a,0) has been removed. b) [2 marks] Draw the heap(s) after the neighbours of b have been updated and the heap has been heapified (see the pseudocode in the lecture Slide 30, Week 9). If there are multiple updates then draw multiple heaps, each of which is obtained after one update. Note that neighbours are updated in the alphabetical order, e.g., 6 must be updated before c. No intermediate steps are required. Follow the dis- cussion on Ed Forum for how to update a node in a heap. 1 a(a,0) 2 a(a,0), bla,4) 3 34 4 10 5 6 S: vertices whose shortest paths have been known 7 8 c) [5 marks] Complete Table 1 with correct answers. You are required to follow strictly the steps in the Dijkstra's algorithm taught in the lecture of Week 9. d) [2 marks] Fill Table 2 with the shortest paths AND the corresponding distances from a to ALL other vertices in the format a →??→v|dy, for instance, a - b 4. a a-a b a → b с d 2485 e f g Priority queue of remaining vertices b(a, 4), c(a, 8), d(a, 6), e(-,co), f(-,co), g(-, oo),h(-,00) Table 1: Complete this table for Part c). h Shortest Paths Table 2: Complete this table for Part d). Distances 0 4 Given a graph as in Fig. 1, we are interested in finding the shortest paths from the source a to all other vertices using the Dijkstra's algorithm and a min-heap as a priority queue. Note that a min-heap is the same as a max-heap, except that the key stored at a parent node is required to be smaller than or equal to the keys stored at its two child nodes. In the context of the Dijkstra's algorithm, a node in the min-heap tree has the format v(pv, dv), where d, is the length of the current shortest path from the source to v and p, is the second to last node along that part (right before v). For example, b(a, 4) is one such node. We treat d, as the key of Node u in the heap, where uela,b,c,d,e, f,g,h}. Source: 3 C 6 h Figure 1: An input graph for the Dijkstra's algorithm. Edge weights are given as integers next to the edges. For example, the weight of the edge (a, b) is 4. a) [1 mark] The min-heap after a(a,0) is removed is given in Fig. 2. The next node to be removed from the heap is b(a, 4). Draw the heap after b(a, 4) has been removed and the heap has been heapified (fixed), assuming that co2oo. No intermediate steps are required. c(a, 8) b(a, 4) d(a, 6) e(-,∞0) f(-∞) g(,00) h(-,∞0) Figure 2: The min-heap (priority queue) after a(a,0) has been removed. b) [2 marks] Draw the heap(s) after the neighbours of b have been updated and the heap has been heapified (see the pseudocode in the lecture Slide 30, Week 9). If there are multiple updates then draw multiple heaps, each of which is obtained after one update. Note that neighbours are updated in the alphabetical order, e.g., 6 must be updated before c. No intermediate steps are required. Follow the dis- cussion on Ed Forum for how to update a node in a heap. 1 a(a,0) 2 a(a,0), bla,4) 3 34 4 10 5 6 S: vertices whose shortest paths have been known 7 8 c) [5 marks] Complete Table 1 with correct answers. You are required to follow strictly the steps in the Dijkstra's algorithm taught in the lecture of Week 9. d) [2 marks] Fill Table 2 with the shortest paths AND the corresponding distances from a to ALL other vertices in the format a →??→v|dy, for instance, a - b 4. a a-a b a → b с d 2485 e f g Priority queue of remaining vertices b(a, 4), c(a, 8), d(a, 6), e(-,co), f(-,co), g(-, oo),h(-,00) Table 1: Complete this table for Part c). h Shortest Paths Table 2: Complete this table for Part d). Distances 0 4
Expert Answer:
Related Book For
Introduction to Algorithms
ISBN: 978-0262033848
3rd edition
Authors: Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest
Posted Date:
Students also viewed these computer network questions
-
If preferred stock sold for $99 a share and $2.95 dividends were paid annually, what would be the required rate of return? show all steps and work
-
Determine the force in each member of the space truss in E9.3.27 if the magnitudes of F and F are 8 kip and 4 kip, respectively. State whether each member is in tension or compression. 2 ft F2 2 ft...
-
A scaling algorithm solves a problem by initially considering only the highest-order bit of each relevant input value (such as an edge weight). It then refines the initial solution by looking at the...
-
Ag Bio Tech (ABT) was organized on January 1, 2013, by four friends. Each organizer invested $10,000 in the company and, in turn, was issued 8,000 shares of common stock. To date, they are the only...
-
1. Is it true that ln x + ln y = ln (x + y) for all positive values of x and y? 2. If f (x) = ln x, find f (e-2). 3. If f (x) = 2x + log (7x - 4), find f(2). 4. If f (x) = ex + ln (x1), find f(0).
-
The August 2014 bank statement for Allison Company and the August 2014 ledger account for cash follow: Outstanding checks at the end of July were for $270, $430, and $320. No deposits were in transit...
-
Explain the concept of cross-docking.
-
Hrabik Corporation issued $600,000, 9%, 10-year bonds on January 1, 2010, for $562,613.This price resulted in an effective-interest rate of 10% on the bonds. Interest is payable semiannually on July...
-
Bond Company is placing an ad in the local paper to advertise its products. The ad will run for one week at a total cost of $5,500. Bond Company has four categories of products as follows: % of floor...
-
Explain why errors in the valuation of inventory at the end of the year are sometimes called counterbalancing or self-correcting.
-
Provide a brief background about the Taco Bell in Mexico, the selected location, and list the major issues faced by the firm in the selection of a location?
-
A Pigouvian tax resolves an externality if it is set equal to: a. the cost of enforcing a quantitative restriction b. marginal private costs of the activity c. marginal social costs of the activity...
-
A tragedy of the commons results when: a. individuals are irrational b. the costs of using a resource are not charged to the user c. transactions costs are high d. property rights are well specified...
-
As societal incomes grow, we expect that the largest increase in spending will be on: a. food b. housing c. health and environment d. clothing
-
Trade will most likely take place between two nations that: a. are very different b. are much the same c. are in close proximity to each other d. have similar access to resources
-
The nation with the lowest opportunity costs of producing a good has: a. a comparative advantage b. an absolute advantage c. an unfair advantage d. a competitive advantage
-
A small pool is 20 feet long, 12 feet wide and 4 feet deep. There are 7.5 gallons of water in every cubic foot. At the rate of 5 gallons per minute, how long will it take to fill this pool?
-
United Business Forms capital structure is as follows: Debt ............................................ 35% Preferred stock ........................... 15 Common equity .......................... 50...
-
Give an inductive definition for an n-tuple by extending the set-theoretic definition for an ordered pair.
-
Show that for all a > 0 and all k such that 0 k-1 k a' < ( + 1)" b(k;n,a/( + 1)) -k( + 1) i=0
-
Show that if f (n) = (n log b a lg k n), where k 0, then the master recurrence has solution T (n) = (n log b a lg k + 1 n). For simplicity, confine your analysis to exact powers of b.
-
Located in Tokyo, Japan, Sony Mobile Communications is a prominent competitor in the worldwide electronics equipment market. Because of stagnant sales in its ultra HD TVs, that division has decided...
-
Cory Rogers of CMG Research was happy to call Nick Thomas to inform him that Auto Concepts survey data were collected and ready for analysis. Of course, Cory had other marketing research projects and...
-
What must be determined before using correlation? Why is it essential?
Study smarter with the SolutionInn App