Skip to content

ivns1/freecodecamp-java-algorithms-forSEP

 
 

Repository files navigation

Report for Assignment 1

freecodecamp-java-algortithms

Name: freecodecamp-java-algortithms

original project: Project URL

our repository: Project URL

Number of lines of code and the tool used to count it: The tool used to count the number of lines of code is cloc (Count Lines of Code) in the WSL terminal, which yields the following result:

cloc results

So, because the chosen programming language is Java, the number of lines of code in the programming language chosen by the group is 29699. Which is ~29.7 KLOC

Programming language: Java

Coverage measurement

Existing tool

The existing coverage tool used is the coverage tool native to IntelliJ. It is used by right clicking the filter containing the tests, which in this case is located in the folder test/java/com.williamfiset.algorithms. And then clicking More/Run/Debug -> Run ‘Tests in com.williamfiset.algorithms’ with Coverage:

And the coverage breakdown:

Your own coverage tool

Isaac

isPrime(n)

URL for commit of coverage

This commit contains changes that include a class used for branch coverage called “BranchCoverageIsaac” and changes in the file “isPrime.Java” that implements the coverage report. Although the original fork did not contain a test file for this function, the coverage results can only be obtained by using the test file I created myself.

modInv(a, m)

URL for commit

This commit contains changes necessary to correctly implement the branch coverage for the function modInv.

Miguel

Since i choose 2 functions inside the same class, i have made in comments which IDs belong to which function:

insert(Node node, T value)

URL for commit of coverage

So all branches from 401 to 406 are covered by the new test InsertTest(). Passing the function from 0% coverage to 100% coverage.

balance(Node node)

URL for commit of coverage

So all branches from 407 to 412 are covered by the new tests. We can see that we also have some coverage on the insert(Node node, T value) function since all tests involve firstly inserting numbers on the Tree.

Mitra

tenarySearch

URL for commit of coverage

The function has three branches and the coverage tool shows that all of them are hit by the test that has been made.

ternarySearchDiscrete

URL for commit of coverage

The coverage tool file that I have made implements both functions. In this commit the file has been extended in order to print the coverage for the ternarySearchDiscrete file. For this function, I have implemented the coverage tool in the same test file as the first function. However, this time, I integrated the coverage tool before finalizing the test file. Therefore, the coverage output indicates that none of the branches have been hit yet, meaning the coverage is currently at 0 percent.

Safia

MaximumSubarrayValue(int[ ] ar)

URL for commit of coverage

To enhance the functionality of this function, the BranchCoverageMaximumSubarray class was integrated into the MaximumSubarray class. This integration was specifically designed to support branch coverage testing, ensuring a comprehensive evaluation of the algorithm's execution paths. Subsequently, the updated function was rigorously tested using a custom test file named MaximumSubarrayTest, which validates the function’s correctness and coverage.

function: lis(int[ ] ar)

URL for the commit of coverage

To enhance the functionality of this function, the BranchCoverageLIS class was integrated into the LongestIncreasingSubsequence class. This integration was specifically designed to support branch coverage testing, ensuring a comprehensive evaluation of the algorithm's execution paths. Subsequently, the updated function was rigorously tested using a custom test file named LongestIncreasingSubsequenceTest, which validates the function’s correctness and coverage.

Coverage improvement

Individual tests

Isaac

isPrimeTest

URL for commit of tests

Old coverage results:

New coverage results:

The coverage improvement is 0.5% in class coverage, 0.2& in method coverage and 0.2% in line coverage. But thhe increase in coverage for the math package is more significant. This happened firstly because the coverage improvement Class, Method and Line all increased after implementing tests for “ïsPrime” because prior to implementation there were no tests for this function. As we can see in the screenshots,

Old coverage result:

New coverage results:

Miguel

Since both functions I chose are in the same class, I decided to commit both functions together and use the same screenshot for both. This is because it would be difficult to show the improvement in one function without including the other, as both functions are interdependent.

insertTest() and (testBalanceLeftLeftCase(), testBalanceLeftRightCase(), testBalanceRightLeftCase(), testBalanceRightRightCase())

URL for commit of test

Coverage has improved since there were previously no tests for the AVLTreeRecursiveOptimized. With the implementation of five tests - one specifically for the insert(Node node, T value) function and four for the balance(Node node) function - we now observe that both methods achieve 100% coverage. Additionally, overall coverage of the AVLTreeRecursiveOptimized has increased, with 13 out of 27 methods now being tested. The coverage for the two functions specifically went from 0% to 100%.

Mitra

TernarySearchTest

URL for commit of tests

These are the old test case results before the test case:

These are the new coverage results after implementing the new test case for it:

Initially, none of the three methods were covered. Now, one out of three methods is covered, increasing the overall method coverage to 33.3%. Additionally, the covered method has 100% branch coverage.

ternarySearchDiscrete

URL for commit of tests

These are the old test case results before the test case:

These are the new coverage results after implementing the new test case for it:

Initially, none of the five methods were covered. Now, three out of five methods are covered, raising the overall method coverage to 60%. Additionally, the covered methods have 85.7% branch coverage, as the test hits 6 out of 7 branches.

Safia

MaxSubarrayTest

URL for commit of tests

old:

This testing for the maxSubarrayValue function was developed from scratch as there was no such in the original codebase. The goal was to validate the function's correctness and performance across the different input scenarios. By creating specific test cases—from single-element arrays to complex mixed-value arrays—the tests aimed to ensure that the maxSubarray function operates reliably and efficiently.

new:

The coverage for the function MaxSubarray has improved from 0% to 100%, as it had initially not been tested at all. After thorough testing, we achieved complete coverage for this function. While the main method was also covered, my primary focus was ensuring comprehensive testing of the MaxSubarray function, as it can be seen in the image below.

LongestIncreasingSubsequenceTest

URL for commit of tests

old:

new:

This testing for the LongestIncreasingSubsequence function was developed from scratch as there was no such in the original codebase. The goal was to validate the function's correctness and performance across the different input scenarios. By creating specific test cases—from empty arrays to complex mixed-value arrays—the tests aimed to ensure that the LongestIncreasingSubsequence function operates reliably and efficiently.

The coverage for the function lis has improved from 0% to 100%, as it had initially not been tested at all. After thorough testing, we achieved complete coverage for this function,as it can be seen in the image below.

Overall

Before modifications:

After modifications:

Statement of individual contributions

Isaac: I contributed by creating tests and implementing a branch coverage tool for the functions isPrime() and modInv(). I also contributed to the project by doing the following: line count, doc setup, contributed to finding project, coverage before improvements, contributed to the readme

Miguel: contributed to finding project, create a coverage tool, create tests for 2 functions, reviewing the coverage, cleaning up the report, merging all branches, update of README file

Mitra: contributed to find the project, create a coverage tool, create tests for 2 functions, reviewing the coverage, merging branches, updating the README.md file, organizing the team

Safia: contributed to find the project, coverage tool creation, 2 functions improved, participating in meetings, update the README.md file, reviewing coverage

About

A collection of algorithms and data structures in java

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • HTML 75.1%
  • Java 24.7%
  • Other 0.2%