Algorithm of prim

Assignment Help Data Structure & Algorithms
Reference no: EM13728142

Introduction

This coursework builds on the first coursework, and requires you to add functionality to your solution to that coursework (or you can use the example solution to the first coursework if you like).

There are two things you have to do.

1) Find an efficient way of cabling together the stations.

Suppose that you have to run cables between the stations, in such a way that every station is connected, directly or indirectly, to every other station. The cables have to run along the routes between the stations. You are required to cable up the network in such a way as to minimise the length of cable used. The appendix explains how you can do this.

2) Find the shortest route between any two points. The completed program must allow the user to find the shortest route between any two points. You can use Dijkstra's algorithm to do this (as set out in lecture 5).

Functional Requirements

In addition to the functional requirements set out in the specification of coursework, the new program must meet the following:

FR5

In addition to the elements set out in the previous specification, the GUI should contain the following elements:

  • A drop down box, or a set of radio buttons, allowing the user to select one of three options labelled "Network", "Span Tree", and "Route". We will refer to this as the Mode
  • Two drop down boxes, each of which lists the names of the stations in the network, and allows the user to select one of those names. We shall refer to these as the Start Station Selectorand the Destination Station Selector.

FR6

If "Span Tree" is selected on the mode selector, and if a network has previously been read, then the graph area should be updated to display a network of cables that cables together the stations in the most efficient way.

FR7

If "Route" is selected on the mode selector, and if a network has previously been read, then the graph area should be updated to show a shortest route between the stations selected by the Start

Station Selector, and Destination Station Selector.

FR8

If "Network" is selected on the mode selector, and if a network has previously been read, then that network is displayed.

Non-functional Requirements

In addition to the non-functional requirements set out in the specification of coursework 1, your application should meet the following:

NFR4

Prim's algorithm should be used to find a minimum spanning tree (see FR6).

NFR5

Dijkstra's  algorithm should be used to find a shortest path between two stations (FR7).

Some notes on implementation:

Some definitions of Dijkstra's algorithm refer to a priority queue of vertices. It is therefore tempting to think that you can use the java class PriorityQueue in an implementation of the algorithm. However there is a catch: The Java PriorityQueue class does not allow the priority of elements to be changed after they have been added. There are ways around this, but it might be simplest not to use a PriorityQueue. If you are tempted to use a SortedSet implementation when implementing Prim's algorithm, bear in mind that the Comparator used when creating a SortedSet must be consistent with the equals() method of the elements it contains. It might be easier to use a List implementation and sort it using the Collections.sort() method.

What you have to submit

You should submit two files:

1) A .zip file containing all of your code, preferably as a Netbeans project.

2) A .doc or .docx file containing a short reflection on the extent to which you feel that you have met the functional and non-functional requirements set out in this document.

Mark Scheme

For meeting FR5 2 marks

For meeting FR6 and NFR4 4 marks

For meeting FR7 and NFR5 4 marks

For meeting FR8 1 marks

For the quality of your code 7 marks

For the reflection on your degree of success2 marks

Appendix: Spanning trees and Prim's algorithm 

If G is a graph then:

A subgraph of G is a graph, each of whose vertices belong to G, and each of whose edges belong to G. In other words it is a part of the graph G.

A spanning tree of G is a connected subgraph of G that is connected, contains all of the vertices of G and contains no cycles.

A minimum spanning tree of G is a spanning tree such that the total length of all the arcs that it contains is as small as possible. In other words there is no other spanning tree for G where the total length of the arcs is shorter.

A minimum spanning tree for G can be obtained by using Prim's algorithm, which generates a minimum spanning tree T as follows.

1) Choose any vertex of the G and add it to T.

2) Look at all the edges in the G that connect a vertex that is in T to one that is not. Out of these edges, choose the shortest, and add it to T (if there is more than one edge that would count as shortest, then you can pick whichever you like).

3) Repeat step 2 until all of the vertices of G are also in T.

Reference no: EM13728142

Questions Cloud

How much heat is transferred from water to cylinder : If I have an aluminum cylinder whose radius is 5cm and height is 4cm and initially its T is 50°C. The aluminum's density is 2.7g/?cm?^3. If I put it into 1000mL water and initially the water is 90°C, (1) what is the final temperature of the cylinder ..
What evidence you found that would lead you to conclusion : What evidence have you found that would lead you to this conclusion? 200 word minimum with references and accompanying citations.
A ray of light traveling through water is incident : 1. Find the angle of refraction if a ray of light traveling through water is incident on glass at an angle of 23°. The index of refraction of water is 1.33 and the index of refraction of glass is 1.52.
Devise a plan to investigate the validity of patients : Devise a plan to investigate the validity of patients' claims of denial of services. This plan should include, but not be limited to, establishing mechanisms to address service denial claims, a human resources component, and a review of related po..
Algorithm of prim : NFR4: Prim's algorithm should be used to find a minimum spanning tree (see FR6). NFR5: Dijkstra's  algorithm should be used to find a shortest path between two stations (FR7).
Which did early river valley civilizations have in common : Which did the early river valley civilizations have in common? They began near rivers because they had developed complex trade networks.
Compare and contrast essay : As you move forward to reflect on the process of writing your Literary Analysis Draft, watch the video Writing the Compare and Contrast Essay, which provides an overview of the writing process. This may seem familiar if you have taken a course in..
Discuss the interactions between europe and the americas : discuss the interactions between TWO of the following three regions: Africa, Europe, and the Americas (Central and South America or the Caribbean).
Explain the importance of situating a society cultural : Explain the importance of situating a society's cultural and artistic expressions within a historical context. Examine the influences of intellectual, religious, political, and socio-economic forces on social, cultural, and artistic expressions.Use t..

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  Your algorithm will keep track of a customers purchases at

your algorithm will keep track of a customers purchases at the local fireworks stand. customers will not know exactly

  Test the database management system functionality

In a report that less than half of all companies validate the in their databases and test database management system's functionality. Explain your answer.

  Question 1a i what is a pointer illustrate with an

question 1a i what is a pointer? illustrate with an exampleii give two advantages of the use of pointers over arraysb i

  Design and implement an avl tree algorithm

Design and implement an AVL tree algorithm that searches a collection of documents. You will be provided with a set of 50 documents and a set of sample queries. First, you will process the documents and store their content (i.e. words / tokens) in..

  Design a simple algorithm by giving pseudocode

Design a simple algorithm by giving pseudocode, for constructing a binary search tree T on n elements in O(nlogn) time with the property that any Find operation on T takes O(logn) time.

  Question about data network

The Minnesota Computer Consulting Group is a fifty person consulting services practice focusing on telecommunications and systems administration that includes Minnesota offices in Minneapolis, St. Paul, and Rochester.

  Include methods to set and get values for each data field

Design a class named MagazineSubscription that has fields for a subscriber's name, the magazine name, and number of months remaining in the subscription. Include methods to set and get the values for each data field.

  Create and implement dynamic programming algorithm

Create and implement such dynamic programming algorithm and examine it. You are not sure if CEO must get invited to party, but you suspect that you might get fired if he is not.

  Read in a height in feet and inches

Write a program that will read in a height in feet and inches (feet should be an integer, while inches should be a float) and will output the equivalent height in meters (as a float). Use at least three functions

  Benefits of dynamic over static arrays

Discuss the benefits of dynamic over-static arrays. Under what conditions will you choose dynamic arrays?

  Write a script that checks the day of the week

Write a script that checks the day of the week, and takes one of two actions depending on the day. If the day is Monday through Friday, print the name of the day.

  Object identifier tree

Assume you worked for a United States based corporation that wanted to develop its own MIB for managing a product line. Where in the object identifier tree would it be registered?

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd