1. Homepage
  2. Programming
  3. CHC5223 Data Structures and Algorithms Assignment 2: Binary search tree

CHC5223 Data Structures and Algorithms Assignment 2: Binary search tree

Engage in a Conversation
CDUTCHC5223Data Structures and AlgorithmsBinary search treeJava

CHC5223 Data Structures and Algorithms CourseNana.COM

20232024 Semester 2 CourseNana.COM

Assignment 2 CourseNana.COM

Value 60% of coursework: Part A is 30% and Part B is 30% Individual work CourseNana.COM

Learning outcomes CourseNana.COM

Students will be able to understand CourseNana.COM

1.1 Data structures
1.2 The applications of data structures
1.3 Object-oriented programming concepts 1.4 Methods for program testing
CourseNana.COM

Students will have acquired skills in: CourseNana.COM

2.1 Data abstraction
2.2 The use of data structures
2.3 Programming at a more advanced level in a high-level object-oriented language 2.4 Program testing and documentation
CourseNana.COM

Students will have acquired skills in: CourseNana.COM

3.1 Self-management
3.2 Learning
3.3 Communication
3.4 Problem solving
3.5 Information technology
CourseNana.COM

Submission requirements CourseNana.COM

The assignment submitted should compressed into a .zip file, the following files should be contained in the compressed file: CourseNana.COM

  • a report as a Microsoft Word document containing text of all your classes. filename format: student ID+CHC5223_CW2_Report.docx CourseNana.COM

  • a .zip file containing the project: the runnable jar file (if available) and all the program’s source texts (.java), including those provided
    filename format:
    student ID +CHC5223_ CW2_Files.zip CourseNana.COM

    Part A binary search tree CourseNana.COM

    General requirements CourseNana.COM

    All your programming must conform to “Java Conventions and Programming Guidelines” – see module Moodle site. CourseNana.COM

    You must paste the source code of all your classes into your report, as text or images. Introduction CourseNana.COM

    The topic of this part of the assignment is binary search trees.
    The interface
    IMemberDB describes methods for an abstract data type (ADT) which holds a CourseNana.COM

    database of Member objects.
    You must implement
    IMemberDB as a binary search tree for Assignment 2. CourseNana.COM

    You must not make any changes to these interfaces. CourseNana.COM

1 of 15 CourseNana.COM

CHC5223 Data Structures and Algorithms 20232024 Semester 2 CourseNana.COM

Requirements CourseNana.COM

Basic rules CourseNana.COM

You must create one executable project after completing all tasks. One Java class should be defined in one .java file respectively. CourseNana.COM

In the report, the source code of each task, together with the corresponding explanation, should be presented separately. CourseNana.COM

Failure to comply with these rules will result in zero marks. CourseNana.COM

Task 1 CourseNana.COM

You must create a Java class called MemberBST that implements the interface IMemberDB. You must use a binary search tree but it does not need to be self-balancing. CourseNana.COM

You must not encapsulate existing implementations of collections in your submission. For example, you must not create a TreeMap object and call methods on that object from your class. Failure to comply with this will result in zero marks for that part. CourseNana.COM

Tip: use String.compareTo to compare strings lexicographically. You can treat uppercase and lowercase as different. (Hash codes have no place in this assignment.) CourseNana.COM

Methods can be implemented either iteratively or recursively. You must not implement the method remove by just building a new tree. CourseNana.COM

You may make use of the supplied source code for the method remove, based on Object- Oriented Programming in Oberon-2, Hanspeter Mössenböck Springer-Verlag 1993, page 78, transcribed into Java by David Lightfoot (see Appendix). CourseNana.COM

The constructor for MemberBST must print the string Binary Search Tree” to System.out. Take care that you have not used a linear search O(n) where you should have used a binary CourseNana.COM

search tree, aiming towards O(logn).
You must give clear rationales and detailed explanations of your design and implementation in CourseNana.COM

the report. CourseNana.COM

Task 2 CourseNana.COM

5 marks CourseNana.COM

5 marks CourseNana.COM

You must make appropriate use of assertions (assert statements) to protect preconditions of the operations. Remember to enable assertion checking for your project. CourseNana.COM

You must give clear rationales and detailed explanations of your design and implementation in the report. CourseNana.COM

2 mark CourseNana.COM

for every addition of a Member (put), for every retrieval of a Member(get), for every deletion of a Member(remove): CourseNana.COM

o theMembername; CourseNana.COM

You must make your class log monitoring information, either to a text file or by calls of System.out.println. CourseNana.COM

It must log (at least): CourseNana.COM

2 of 15 CourseNana.COM

CHC5223 Data Structures and Algorithms 20232024 Semester 2 CourseNana.COM

o the sequence of nodes of the tree visited. Paste your log into your report. CourseNana.COM

We have supplied a main program CHC5223.java for your use with this assignment. The name of the file is set in the static variable filename. CourseNana.COM

Sample files sampleMembersUK.csv and sampleMembersUS.csv each contain 500 members in this format. CourseNana.COM

3 marks CourseNana.COM

You must give clear rationales and detailed explanations of your design and implementation in the report. CourseNana.COM

3 mark CourseNana.COM

Task 4 CourseNana.COM

You must devise a test plan for your implementation. Be sure to check (among many other cases). CourseNana.COM

3 mark CourseNana.COM

You must give clear evidence and detailed explanations of your test in the report, including your test plan, test data used, expected results and actual results. You must show your actual results and the logging information copied from your log file or the output pane of your IDE. Do not simply state “test passed”, or similar. CourseNana.COM

5 mark CourseNana.COM

Task 6 CourseNana.COM

You must comment on the time efficiency and space efficiency of your implementation of the binary search tree. CourseNana.COM

By using the supplied main program, or by other means, you must test your MemberBST. CourseNana.COM

You must give clear rationales and detailed explanations in the report. CourseNana.COM

3 of 15 CourseNana.COM

2 mark total 30 marks CourseNana.COM

CHC5223 Data Structures and Algorithms 20232024 Semester 2 CourseNana.COM

Part B graphs and pathfinding CourseNana.COM

The topic of this part of Assignment 2 is graphs and pathfinding. CourseNana.COM

General requirements CourseNana.COM

All your programming must conform to “Java Conventions and Programming Guidelines”. You must paste the source code of all your classes into your report, as text, not images. You must implement all necessary data structures using only arrays. CourseNana.COM

When programming in Java it is usual to make use of collection classes from the Java class library. However, if you need to program in some other language such classes, or their equivalents, will not necessarily be available. CourseNana.COM

Task 1 CourseNana.COM

Find or devise a transport network it need not be real, but it must be realistic. It must be an undirected, connected graph, with no loops. It must have at least eight nodes. CourseNana.COM

Each node should have a name (with no spaces in it) and x and y positions (0 x < 256 and
0
y < 256) indicating the approximate position of the node on a map with a 256 × 256 grid (y increasing downwards). CourseNana.COM

The links must contain information about the distance between the nodes it connects. The distance can be measured in suitable units of length, such as km, or time, such as minutes. CourseNana.COM

The links between them must be such that there are several pairs of nodes that are linked by more than one route. CourseNana.COM

You must sketch your network and include it in your report. The sketch must show each node annotated with its name and located on the sketch at its x and y position. The sketch must show each link annotated with its distance. You can make the sketch by hand but if you do so you will need to scan it to include in your report. CourseNana.COM

Task 2 CourseNana.COM

You must express your network as a text file using the syntax:
“station” name x y
“link” station station distance
Each station must have been defined in a station line before being cited in a link line. Include the content of the text file in your report. CourseNana.COM

Task 3 CourseNana.COM

2 marks CourseNana.COM

You must implement Java classes StackInt, QueueInt, ListInt and SetInt. These will be subclasses respectively of abstract classes AbsStackInt, AbsQueueInt, AbsListInt, AbsSetInt, whose source is provided and shown in the appendixes. These are given as abstract classes (to be ‘sub-classed’) rather than as interfaces (to be ‘implemented’) partly because they are all ‘bounded’, that is, with limited capacity because of being implemented by arrays, and also to allow us to give you hints on how to implement them. CourseNana.COM

4 of 15 CourseNana.COM

2 marks CourseNana.COM

CHC5223 Data Structures and Algorithms 20232024 Semester 2 CourseNana.COM

The required behaviour of the methods of the classes is indicated as pre- and post-conditions in comments. CourseNana.COM

You must give clear rationales and detailed explanations of your design and implementation in the report. CourseNana.COM

4 marks CourseNana.COM

Task 4 CourseNana.COM

You must make appropriate use of assertions (assert statements) to protect preconditions of the operations. Remember to enable assertion checking for your project. CourseNana.COM

1 mark CourseNana.COM

Task 5 CourseNana.COM

By using JUnit or otherwise you must test your implementations of StackInt, QueueInt, ListInt and SetInt. To do this, create objects of each class in which capacity is set to a low value, such as 10. You will set it to something larger when deploying the classes later. CourseNana.COM

You must give clear evidence and detailed explanations of your design and implementation in the report, including the test plan, test data used, expected results, and actual results. Your actual results must be shown either as screenshot images or as text copied from the output pane of the development toolkit. CourseNana.COM

4 marks CourseNana.COM

Task 6 CourseNana.COM

You must create a Java class StationInfo to implement the Java interface IStationInfo (supplied). 1 mark CourseNana.COM

Task 7 CourseNana.COM

You must create a Java class to define an adjacency matrix
final double NO_LINK = Double.MAX_VALUE; // was erroneous double.MAX_VALUE int numStations; // 0 <= numStations <= capacity CourseNana.COM

double distance[ ][ ];
where, for all i, j in 0 <= numStations <= capacity
CourseNana.COM

distance [i][j] is the distance from station with number i to station with number j distance [i][j] is equal to distance [j][i]
distance [i][i] = NO_LINK
CourseNana.COM

Task 8 CourseNana.COM

and also define a list of objects of class StationInfo held in an array. Task 9 CourseNana.COM

You must create a Java method in this class that reads a text file containing the textual description of your network and builds the corresponding list of stations and the matrix of links. CourseNana.COM

5 of 15 CourseNana.COM

CHC5223 Data Structures and Algorithms 20232024 Semester 2 CourseNana.COM

You must perform as many validity checks in this as you can and report any errors. Include the text of this class in your report. CourseNana.COM

You must give clear rationales and detailed explanations of your design and implementation in the report. CourseNana.COM

2 marks CourseNana.COM

Task 10 CourseNana.COM

Use print statements to show the contents of the list and the matrix after using your program to build them from the data held in your text file. Copy the results into your report. CourseNana.COM

You must give clear rationales and detailed explanations of your design and implementation in the report. CourseNana.COM

2 marks CourseNana.COM

Task 11 CourseNana.COM

You must write Java methods (as in Appendixes) to perform a depth-first traversal from a given node of your network and a breadth-first traversal from the same node, making use of the algorithms given in the appendix. Include the methods text and the resulting sequence of node names in your report. CourseNana.COM

You must give clear rationales and detailed explanations of your design and implementation in the report. CourseNana.COM

4 marks CourseNana.COM

Task 12 CourseNana.COM

You must implement Dijkstra’s algorithm (as in Appendix) making use of the data structures you have constructed, to find and display the shortest path between two stations in your network. You must also ‘instrument’ your implementation to count the number of iterations of the while loop CourseNana.COM

You must give clear rationales and detailed explanations of your design and implementation in the report. CourseNana.COM

4 marks CourseNana.COM

Task 13 CourseNana.COM

You must give clear rationales and detailed explanations of the difference between Dijkstra’s algorithm and A* algorithm and state how their behavior would differ in the case of your network. CourseNana.COM

4 marks total 30 marks CourseNana.COM

6 of 15 CourseNana.COM

CHC5223 Data Structures and Algorithms 20232024 Semester 2 CourseNana.COM

Obtaining help CourseNana.COM

It is encouraged to request further clarification on what is required for this assignment. Please try to do this during normal contact time and avoid asking for such help in the last week before the deadline. CourseNana.COM

You can discuss the requirements and the material covered in the assignment with others but what you create must be all your own work. Be careful to avoid collusion. CourseNana.COM

Declare in your report any help you have received other than that from the module teaching team. CourseNana.COM

Feedback CourseNana.COM

In addition to the written feedback that we aim to provide within the normal interval, you will be able to obtain fast, brief, verbal formative feedback and help on correcting your work at your practical classes. CourseNana.COM

7 of 15 CourseNana.COM

CHC5223 Data Structures and Algorithms CourseNana.COM

20232024 Semester 2 CourseNana.COM

Appendix: remove private class Node { CourseNana.COM

private Member data;
private Node left, right;
public Node(Member s) {data = s; left = null; right = null;}
CourseNana.COM

} // Node CourseNana.COM

private Node root; CourseNana.COM

public Member remove(String name){
// based on Object-Oriented Programming in Oberon-2 // Hanspeter Mössenböck Springer-Verlag 1993, page 78 // transcribed into Java by David Lightfoot
CourseNana.COM

// put assert statement for preconditions here CourseNana.COM

Node parent = null, del, p = null, q = null;
Member result;
del = root;
while (del != null && !del.data.getName().equals(name)) {
CourseNana.COM

parent = del;
if (name.compareTo(del.data.getName()) < 0)
CourseNana.COM

del = del.left; else CourseNana.COM

del = del.right;
}// del == null || del.data.getName().equals(name))
CourseNana.COM

if(del != null) { // del.data.getName().equals(name) // find the pointer p to the node to replace del
if (del.right == null) p = del.left;
else if (del.right.left == null) {
CourseNana.COM

p = del.right; p.left = del.left; } else { CourseNana.COM

p = del.right;
while (p.left != null) {q = p; p = p.left;}
CourseNana.COM

q.left = p.right; p.left = del.left; p.right = del.right; } CourseNana.COM

if(del == root) root = p;
else if (del.data.getName().compareTo(parent.data.getName()) < 0)
CourseNana.COM

parent.left = p;
else parent.right = p;
// reduce size of tree by one result = del.data;
CourseNana.COM

}
else result = null;
CourseNana.COM

return result; } // remove CourseNana.COM

Get in Touch with Our Experts

WeChat (微信) WeChat (微信)
Whatsapp WhatsApp
CDUT代写,CHC5223代写,Data Structures and Algorithms代写,Binary search tree代写,Java代写,CDUT代编,CHC5223代编,Data Structures and Algorithms代编,Binary search tree代编,Java代编,CDUT代考,CHC5223代考,Data Structures and Algorithms代考,Binary search tree代考,Java代考,CDUThelp,CHC5223help,Data Structures and Algorithmshelp,Binary search treehelp,Javahelp,CDUT作业代写,CHC5223作业代写,Data Structures and Algorithms作业代写,Binary search tree作业代写,Java作业代写,CDUT编程代写,CHC5223编程代写,Data Structures and Algorithms编程代写,Binary search tree编程代写,Java编程代写,CDUTprogramming help,CHC5223programming help,Data Structures and Algorithmsprogramming help,Binary search treeprogramming help,Javaprogramming help,CDUTassignment help,CHC5223assignment help,Data Structures and Algorithmsassignment help,Binary search treeassignment help,Javaassignment help,CDUTsolution,CHC5223solution,Data Structures and Algorithmssolution,Binary search treesolution,Javasolution,