Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

4.[20] Prim's algorithm for Minimum Spanning Tree (MST) and Dijkstra's algorithm for Shortest Paths are both greedy algorithms. The two algorithms proceed in quite similar,

image text in transcribed
4.[20] Prim's algorithm for Minimum Spanning Tree (MST) and Dijkstra's algorithm for Shortest Paths are both greedy algorithms. The two algorithms proceed in quite similar, but in fact different steps. (a) Very briefly, state how the two algorithms are different? (You don't need to give the algo- rithms.) (b) Draw an example of 3-node weighted graph, so that Prim's and Dijkstra's algorithms give different results 5.[20] A Bucket-Sort algorithm and an example run are given below. BUCKET-SORT(A) 1, n length[A] 2, for i i to n 3. do insert Ali] into list BllnAli 4, for i 0 to n-1 5. do sort list Bi] with insertion sort 6. concatenate the lists Bo), Blu.. Bn-1 together in order 4269 5 72 6194 10 tb) (a) What are the conditions for the algorithm to work? (b) Given the conditions in (a), what's the algorithm's complexity in terms of "big-O" (c) Give a "bad instance" of 10 decimal numbers, for which this algorithm will perform poorly. (d) ) Notice line 5 of the algorithm. What is the reason we want to use insertion sort, instead of other sorting methods (for example, selection sort), here

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction To Constraint Databases

Authors: Peter Revesz

1st Edition

1441931554, 978-1441931559

More Books

Students also viewed these Databases questions

Question

4. How can speakers manage speaking anxiety?

Answered: 1 week ago

Question

2. Show the trainees how to do it without saying anything.

Answered: 1 week ago