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

- Programhelp With ,Help With C++ Course... 2022-05-10
- Help With Data Programming,Help With C... 2022-05-10
- 5Cce2sashelp With ,Python，Java Progra... 2022-05-10
- Help With Program Programming,Help Wit... 2022-05-09
- Help With Csci 3110,Help With Java，Py... 2022-05-09
- Mth2222help With ,Help With C/C++，Pyt... 2022-05-09
- Cse3bdchelp With ,Help With Sql Progra... 2022-05-08
- Help With Cis 468,Help With Java，Pyth... 2022-05-08
- Comp Sci 4094/4194/7094 Assignment 3 D... 2022-05-07
- Cs 178: Machine Learning & Data Mining... 2022-05-07
- Data7703 Assignment 4 2022-05-07
- Data Programminghelp With ,Help With S... 2022-04-25
- Help With Ait681 Course,Help With Pyth... 2022-04-25
- Cse121l Programminghelp With ,Help Wit... 2022-04-25
- Help With Iti1120,Help With Java，C/C+... 2022-04-25
- Cmt304help With ,Help With C++，Python... 2022-04-25
- Help With Engn4528,Matlab Programmingh... 2022-04-24
- Help With Fin 2200,Help With Java，Pyt... 2022-04-24
- Bism 7255Help With ,Help With Java，Py... 2022-04-23
- Comp202help With ,Help With Java Progr... 2022-04-23

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

© 2021 www.asgnhelp.com

Programming Assignment Help！