Algorithms and Data Structures (M) Assessed Coursework This coursework is worth a total of 30 marks and contributes 20% towards the course credit. This coursework should take between 6 and 8 hours to complete. It is divided into two parts: 1. Exercise in using the Java Map interface and in using a Map implementation (namely, HashMap). Note that we do not study the Map ADT until the end of the course. The purpose of this exercise is not to know how a hashmap is implemented, rather how to use it. That is, to demonstrate that you understand how to use Java interfaces and implementation classes (from your experience with other ADTs, and the examples using interfaces and implementations, like those from the introduction slides seen in Lecture 1). 2. Implementation of a Graph ADT. Note that graphs are covered in various textbooks but don’t be tempted to use any implementation you see in them. This question is very specific, and you must follow the instructions completely. You will submit your code for testing together with a description document. In your description document you should provide outline code containing method signatures and detailed comments explaining how your methods work, what underlying (array) algorithms you would use and the complexity of each of the algorithms used. Most of the marks will be awarded for your description. Submit all required parts of your solutions to both parts of the assignment (see full submission details near the end of this document). All classes and pdf documents should contain your name and student number. You should submit your coursework by Monday March 18th at 4.30 pm. 1. [5 marks] This part of the exercise is to show that you understand the Java interface Map and how to use one of its implementations, HashMap. You have been provided with an outline of a class, AssE1_outline.java. You should make a copy of AssE1_outline.java and rename it AssE1.java. ADS Assessed Coursework 20241
public interface Graph<F extends Comparable<F>> { public boolean addEdge (Edge<F> e);/ add edge e to graph if its vertices are already in graph/ and e doesn’t already exist in graph/ return true if successful and false otherwise public boolean addVertex (Vertex<F> v);/ Add vertex v to graph if graph doesn’t already contain v/ or any vertex with the same label as v/ return true if successful and false otherwise public boolean deleteEdge (Edge<F> e); / delete edge e if it is present in graph/ return true if successful and false otherwise public boolean deleteVertex (Vertex<F> v); / delete vertex v if it is present in graph, and all edges that contain v/ return true if successful and false otherwise. public Set<Vertex<F>> vertexSet(); //return a set containing all vertices public Set<Edge<F>> edgeSet(); //return a set containing all edges } Box 1: Graph interface Implement the Graph interface as a class ArrayGraph.java whose instance variables consist of:- two arrays: vertices and edges, of type Vertex<F> and Edge<F> respectively containing the current vertices and edges in the graph, each array sorted in ascending order, and- two integer variables representing the current numbers of vertices and edges. Note that you must also implement (generic) Vertex and Edge classes, and you must decide for yourself exactly how vertices and edges should be compared (and thus ordered). This information should be included in your description document, which is described below. You may assume that any instantiation of your class has at most 20 vertices and at most 50 edges at any time. You will be submitting your full Java code, which I will run using a test program like ADS Assessed Coursework 20244
the one provided – TestGraph.java. I will not be looking at your code in detail other than for this testing stage, although I may look closer to determine why it doesn’t run. You must ensure that your program runs with the provided test class (e.g., ensure that your classes contain the necessary constructors). In addition to your code, you should include a pdf document graphDescription.pdf, describing your implementation. This document should not contain large amounts of code (although you may find that it helps to provide fragments, and you should include important parts of your code, such as your class signatures and instance variables), it is your description that is important. You also do not need to provide full implementations of the Vertex and Edge classes within the document but should indicate their instance variables and the signatures of any methods within those classes that you refer to in your description. If you require any helper methods, give the signatures (and a commented description) of each method in your document, but you should not include the full implementation. Note that if you program does not work, include details of why you believe it does not in this document. For each of the Graph methods, analyse the time complexity of the underlying (array) algorithms used (and state what these underlying algorithms are). Summary: Provide full code plus description document containing outline code with detailed, clear comments, and complexity analysis of your implementation of the Graph methods. Submission instructions: You should submit a single zipped folder named xxxxxxxx.zip where xxxxxxxx is replaced with your student id (e.g. 0123456a). The folder should contain two subfolders: AEx1 and AEx2 containing your solutions for parts 1 and 2. AEx1 will contain two files: AssE1.java, and AssE1_output.pdf only. AEx2 will contain four files: Vertex.java, Edge.java, ArrayGraph.java, and graphDescription.pdf only. Marking scheme: 1. program runs as expected and output provided: 5 marks. 2. Vertex.java, Edge.java, ArrayGraph.java work with test class: 5 marks. Class signatures : 4 marks. Node and Edge descriptions: 6 marks. graphDescription: Descriptions of Graph methods (including descriptions of any helper methods): 6 marks. Complexity analysis of Graph: 4 marks.
WX:codehelp
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。