Commit 394f701c authored by Fokion Zervoudakis's avatar Fokion Zervoudakis

Rename test methods. Update Javadoc.

parent c07f4256
......@@ -12,7 +12,7 @@ class DpKnapsack {
/**
Uses recursive (top-down) dynamic programming with memoization to
calculate solve the knapsack problem.
solve the knapsack problem.
<ul>
<li>time_worst=O(mn)
<li>space_worst=O(mn)
......
......@@ -4,7 +4,13 @@ import search.BinSearch;
class DpLis {
/**
Asymptotic analysis:
Uses binary search to find a longest increasing sub-sequence for a given
array. The sub-sequence does not have to be contiguous or unique.
<p>For the first 16 terms of the binary van der Corput sequence: 0, 8, 4,
12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15
<p>one longest increasing sub-sequence is: 0, 2, 6, 9, 11, 15
<p>Other increasing sub-sequences with length six are also available.
<p>Asymptotic analysis:
<ul>
<li>time_worst=O(n log n)
<li>space_worst=O(n)
......
......@@ -14,27 +14,27 @@ class DpLisTest {
}
@Test
void itReturnsTheLisOfZeroElements() {
void itReturnsTheListOfZeroElements() {
assertEquals(0, lis.len(new int[0]));
}
@Test
void itReturnsTheLisOfOneElement() {
void itReturnsTheListOfOneElement() {
assertEquals(1, lis.len(new int[] { 1 }));
}
@Test
void itReturnsTheLisOfManyAscendingElements() {
void itReturnsTheListOfManyAscendingElements() {
assertEquals(3, lis.len(new int[] { 1, 2, 3 }));
}
@Test
void itReturnsTheLisOfManyDescendingElements() {
void itReturnsTheListOfManyDescendingElements() {
assertEquals(1, lis.len(new int[] { 3, 2, 1 }));
}
@Test
void itReturnsTheLisOfManyUnorderedElements() {
void itReturnsTheListOfManyUnorderedElements() {
// The first 16 terms of the binary van der Corput sequence:
var A = new int[] { 0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15 };
assertEquals(6, lis.len(A));
......
......@@ -14,27 +14,27 @@ class LisTest {
}
@Test
void itReturnsTheLisOfZeroElements() {
void itReturnsTheListOfZeroElements() {
assertEquals(0, lis.len(new int[0]));
}
@Test
void itReturnsTheLisOfOneElement() {
void itReturnsTheListOfOneElement() {
assertEquals(1, lis.len(new int[] { 1 }));
}
@Test
void itReturnsTheLisOfManyAscendingElements() {
void itReturnsTheListOfManyAscendingElements() {
assertEquals(3, lis.len(new int[] { 1, 2, 3 }));
}
@Test
void itReturnsTheLisOfManyDescendingElements() {
void itReturnsTheListOfManyDescendingElements() {
assertEquals(1, lis.len(new int[] { 3, 2, 1 }));
}
@Test
void itReturnsTheLisOfManyUnorderedElements() {
void itReturnsTheListOfManyUnorderedElements() {
// The first 16 terms of the binary van der Corput sequence:
var A = new int[] { 0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15 };
assertEquals(6, lis.len(A));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment