联系方式

  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-23:00
  • 微信:codinghelp

您当前位置:首页 >> Java编程Java编程

日期:2021-05-19 10:09

Divide-and-Conquer and Dynamic Programming

Assignment

2

Tasks for this week

? Implement Merge sort (MergeSort class, mergeSort and merge methods)

? Implement Karatsuba multiplication (MultiplicationAlgorithm class and KMultiply method)

? Implement Edit Distance computation (EditDistance class and minDistance method)

? The code structure/skeleton is available on Wattle

? Submission Guidelines

? The last slide contains information about the submission

? Read it carefully to avoid losing marks!

3

Task 1 – Merge Sort (1 mark)

? Implement the following methods in the MergeSort.java:

1. Method mergeSort()

This method uses divide-and-conquer to sort an array. It must use merge() method

2. Method merge()

This method merges two sorted subarrays

Reference: Lecture 5 Algorithms Part I, slide 20

How to test your code?

Use the MergeSortTest.java file to check whether your implementation passes the test cases or not.

It may be used as an indicator that your code is working correctly. Please be aware that we will use

additional test cases to verify and assess your code.

What is tracker class?

The tracker.java is used for marking purpose to track divide-and-conquer calls. Do not modify any

code associated with the tracker. Otherwise, you will be penalized for violation.

4

Task 2 – Karatsuba Multiplication (1 mark)

? Implement the following method in the MultiplicationAlgorithm.java:

1. Method KMultiply()

This method uses Karatsuba multiplication to compute the product x times y.

x and y are two n-digit input numbers

Reference: Lecture 5 Algorithms Part I, slide 49

How to test your code?

Use the KMultiplyTest.java file to check whether your implementation passes the test cases or not.

It may be used as an indicator that your code is working correctly. Please be aware that we will use

additional test cases to verify and assess your code.

What is tracker class?

The tracker.java is used for marking purpose to track divide-and-conquer calls. Do not modify any

code associated with the tracker. Otherwise, you will be penalized for violation.

5

Task 3 – Edit Distance (1 mark)

? Implement the following method in the EditDistance.java:

1. Method minDistance()

This method computes the minimal total cost of a sequence of character edits between two strings.

The costs of character edits are defined in EditCost enum.

Do not modify the character edit costs. Otherwise, your answers will not be marked correctly.

Reference: Lecture 7 Algorithms Part III, slides 10-14

How to test your code?

Use the EditDistanceTest.java file to check whether your implementation passes the test cases or

not. It may be used as an indicator that your code is working correctly. Please be aware that we will use

additional test cases to verify and assess your code.

6

Submission Guidelines

? Assignment deadline: see the deadline on Wattle (always!)

? Submission mode: via Wattle (Assignment)

Submission format (IMPORTANT):

? Upload only your final version of:

MergeSort.java (for task 1), MultiplicationAlgorithm.java (for task 2) and EditDistance.java (for task 3) to Wattle

? Each test case must run for at most 1000ms, otherwise it will fail (zero marks).

? Do not change the file names

? Do not upload any other files (only the specified files are needed)

? Do not upload a folder (your submission should be only three java files).

? The answers will be marked by an automated marker.

? Do not change the structure of the source code including class name, package structure, etc.

? You are only allowed to edit the designated code segment indicated in the comments.

? Do not import packages outside of the standard java SE package. The list of available packages can be found here:

https://docs.oracle.com/en/java/javase/12/docs/api/index.html

? Any violation of the submission format will result in zero marks


版权所有:留学生编程辅导网 2020 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。 站长地图

python代写
微信客服:codinghelp