Home Page > > Details

CSCI 2520 Data Structures and Applications

Assignment Four

Deadline: 23:55, May. 16, 2020

Total Marks: 100

Submission:

In this Assignment, you need to answer question 1 and question 2 in one pdf file. For question 3 and

4, you need to provide .c file for each question, which can be compiled and give the correct answer,

the name should be q3.c and q4.c respectively.

Then compress all 4 files (one pdf file for q1 q2 and three .c files for q3 and q4 respectively) as one

zip named as your_student_id_assign4.zip and submit it via Blackboard.

1. Shortest-Path Algorithm (20 marks)

Use Dijkstra’s algorithm to calculate the shortest distance from VS to all vertices and the shortest

path from VS to VF.

Note: Please use the table used in lecture (Shortest-Path Algorithm) to represent each step.

Example:

Initial Step Step 1

2. Minimum Spanning Tree (20 marks)

Given an undirected graph, find the minimum spanning tree. The number of the edge connecting

vertex a and vertex b is ab. Like the edge with weight 1 in the graph, its number is 02.

(1) Use Prim’s Algorithm starting from vertex 0 to find the minimum spanning tree, write the

number of the edge added into the minimum spanning tree in turn (if there are many edges

satisfy requirement, choose the edge with minimum number). Please use the table used in

lecture (Prim’s Algorithm) to represent each step.

Example:

Initial Step Step 1

(2) Use Kruskal’s Algorithm and write the number of the valid edge with minimum merging cost

in turn (if there are many edges satisfy requirement, choose the edge with minimum number).

3. The diameter of a graph (30 marks)

Definition: The distance d(u, v) between two vertices u and v is defined as the length of a

shortest path from u to v. The diameter of a graph is the greatest distance between any pair of

vertices.

Now give you a undirected graph, get the diameter of the graph.

The first line of input is the number of nodes N and edges M. Next M lines, contains three

positive integers x, y, w means an undirected edge between vertex x and vertex y with length w.

(The data guarantees that the graph is connected.)

Input:

5 7

1 2 3

1 4 4

4 5 2

2 3 3

3 5 1

1 3 2

3 4 1

Output:

4

4. The power of the team. (30 marks)

We want to build the best team to solve a problem. Now there are n great people on the

waiting list. Everyone has different strengths and weaknesses. The power of the team is the sum of

the strength of the teammate multiplied by the minimum weakness of the team.(Cannikin Law).

Since the budget is not sufficient, we can only choose at most k people. You need to solve this

problem by finding the maximum power of the team you can have.(Hint: use heap to solve it)

The first line of input is n and k. (1<= k <= n <= 10000)

The following two lines are the strengths and weaknesses of the n people. All the values are

less than 10000.

For example:

Input:

5 3

1 2 3 4 5

5 4 3 2 1

Output:

18

(There are two different ways to get the answer. You can choose the 1, 2, 3 and 2, 3, 4 )

Contact Us(Ghostwriter Service)

- QQ：99515681
- WeChat：codinghelp
- Email：99515681@qq.com
- Work Time：8:00-23:00

- Cmpsc 131Help With ,Python Programming... 2023-05-04
- Data Programminghelp With ,Python，Jav... 2023-05-04
- Help With Program,Help With Java Progr... 2023-05-04
- Kit107help With ,Help With C++ Program... 2023-05-04
- Help With Program,Help With Java/Pytho... 2023-05-03
- Cs520 Programminghelp With ,Help With ... 2023-05-03
- Data Programminghelp With ,Help With C... 2023-05-03
- Programhelp With ,Help With Java，C++ ... 2023-05-03
- Help With Stat3010,Help With R Program... 2023-05-03
- Help With Comp5310,Help With Java，Pyt... 2023-05-03
- Help With Qbus6820,Help With C++，Java... 2023-05-02
- Help With Com3504,Help With Python，C+... 2023-05-02
- Help With Finc6021,Help With Python，C... 2023-05-02
- Fit2099help With ,Help With Python，Ja... 2023-05-02
- Help With Math60082,Help With Java，Py... 2023-05-02
- Help With Comp30024,Help With Python P... 2023-05-01
- Help With Csc246/446,Help With Python，... 2023-05-01
- Help With Comp30023,Help With C++ Prog... 2023-05-01
- Comp2006help With ,Help With C/C++ Pro... 2023-05-01
- Help With Finm7409,Help With Java，C++... 2023-05-01

Contact Us - Email：99515681@qq.com WeChat：codinghelp

© 2021 www.asgnhelp.com

Programming Assignment Help！