Skip to content

Commit a45cc54

Browse files
committed
Added new solutions to chapter 25 exercises
1 parent 3575e01 commit a45cc54

22 files changed

+876
-189
lines changed

README.md

+14-17
Original file line numberDiff line numberDiff line change
@@ -29,27 +29,24 @@ to check your work.
2929
<li><a href="https://github.com/HarryDulaney/java-programming-daniel-liang-10th/tree/master/src/ch_12"><strong>Chapter 12</strong></a> - Exception Handling and Text I/O</li><br>
3030
<li><a href="https://github.com/HarryDulaney/java-programming-daniel-liang-10th/tree/master/src/ch_13"><strong>Chapter 13</strong></a> - Abstract Classes and Interfaces</li><br>
3131
<li><a href="https://github.com/HarryDulaney/java-programming-daniel-liang-10th/tree/master/src/ch_14"><strong>Chapter 14</strong></a> - JavaFx Basics</li><br>
32-
<li><a href="https://github.com/HarryDulaney/java-programming-daniel-liang-10th/tree/master/src/ch_15"><strong>Chapter 15</strong></a> - Event-Driven Programming and Animations</li><br>
33-
<li><a href="https://github.com/HarryDulaney/java-programming-daniel-liang-10th/tree/master/src/ch_16"><strong>Chapter 16</strong></a> - JavaFx UI Controls and Multimedia</li><br>
32+
<li><strong>Chapter 15</strong> - Event-Driven Programming and Animations</li><br>
33+
<li><strong>Chapter 16</strong> - JavaFx UI Controls and Multimedia</li><br>
3434
<li><a href="https://github.com/HarryDulaney/java-programming-daniel-liang-10th/tree/master/src/ch_17"><strong>Chapter 17</strong></a> - Binary I/O</li><br>
3535
<li><a href="https://github.com/HarryDulaney/java-programming-daniel-liang-10th/tree/master/src/ch_18"><strong>Chapter 18</strong></a> - Recursion</li><br>
3636
<li><a href="https://github.com/HarryDulaney/java-programming-daniel-liang-10th/tree/master/src/ch_19"><strong>Chapter 19</strong></a> - Generics</li><br>
3737
<li><a href="https://github.com/HarryDulaney/java-programming-daniel-liang-10th/tree/master/src/ch_20"><strong>Chapter 20</strong></a> - Lists, Stacks, Queues, and Priority Queues</li><br>
3838
<li><a href="https://github.com/HarryDulaney/java-programming-daniel-liang-10th/tree/master/src/ch_21"><strong>Chapter 21</strong></a> - Sets and Maps</li><br>
39+
<li><a href="https://github.com/HarryDulaney/java-programming-daniel-liang-10th/tree/master/src/ch_25"><strong>Chapter 25</strong></a> - Binary Search Trees </li><br>
3940
<span><i> Looking to contribute? There's more to do: </i></span><br><br>
40-
<li><!--<a href="https://github.com/HarryDulaney/java-programming-daniel-liang-10th/tree/master/src/">--><strong>Chapter 22</strong></a> - Developing Efficient Algorithms</li><br>
41-
<li><!--<a href="https://github.com/HarryDulaney/java-programming-daniel-liang-10th/tree/master/src/">--><strong>Chapter 23</strong></a> - Sorting</li><br>
42-
<li><!--<a href="https://github.com/HarryDulaney/java-programming-daniel-liang-10th/tree/master/src/">--><strong>Chapter 24</strong></a> - Implementing Lists, Stacks, Queues, and Priority Queues</li><br>
43-
<li><!--<a href="https://github.com/HarryDulaney/java-programming-daniel-liang-10th/tree/master/src/">--><strong>Chapter 25</strong></a> - Binary Search Trees </li><br>
44-
<li><!--<a href="https://github.com/HarryDulaney/java-programming-daniel-liang-10th/tree/master/src/">--><strong>Chapter 26</strong></a> - AVL Trees </li><br>
45-
<li><!--<a href="https://github.com/HarryDulaney/java-programming-daniel-liang-10th/tree/master/src/">--><strong>Chapter 27</strong></a> - Hashing</li><br>
46-
<li><!--<a href="https://github.com/HarryDulaney/java-programming-daniel-liang-10th/tree/master/src/">--><strong>Chapter 28</strong></a> - Graphs and Applications</li><br>
47-
<li><!--<a href="https://github.com/HarryDulaney/java-programming-daniel-liang-10th/tree/master/src/">--><strong>Chapter 29</strong></a> - Weighted Graphs and Applications </li><br>
48-
<li><!--<a href="https://github.com/HarryDulaney/java-programming-daniel-liang-10th/tree/master/src/">--><strong>Chapter 30</strong></a> - Multithreading and Parallel Programming</li><br>
49-
<li><!--<a href="https://github.com/HarryDulaney/java-programming-daniel-liang-10th/tree/master/src/">--><strong>Chapter 31</strong></a> - Networking </li><br>
50-
<li><!--<a href="https://github.com/HarryDulaney/java-programming-daniel-liang-10th/tree/master/src/">--><strong>Chapter 32</strong></a> - Java Database Programming</li><br>
51-
<li><!--<a href="https://github.com/HarryDulaney/java-programming-daniel-liang-10th/tree/master/src/">--><strong>Chapter 33</strong></a> - Java Server Faces</li><br>
52-
53-
54-
41+
<li><!--<a href="https://github.com/HarryDulaney/java-programming-daniel-liang-10th/tree/master/src/">--><strong>Chapter 22</strong><!--</a>--> - Developing Efficient Algorithms</li><br>
42+
<li><!--<a href="https://github.com/HarryDulaney/java-programming-daniel-liang-10th/tree/master/src/">--><strong>Chapter 23</strong><!--</a>--> - Sorting</li><br>
43+
<li><!--<a href="https://github.com/HarryDulaney/java-programming-daniel-liang-10th/tree/master/src/">--><strong>Chapter 24</strong><!--</a>--> - Implementing Lists, Stacks, Queues, and Priority Queues</li><br>
44+
<li><!--<a href="https://github.com/HarryDulaney/java-programming-daniel-liang-10th/tree/master/src/">--><strong>Chapter 26</strong><!--</a>--> - AVL Trees </li><br>
45+
<li><!--<a href="https://github.com/HarryDulaney/java-programming-daniel-liang-10th/tree/master/src/">--><strong>Chapter 27</strong><!--</a>--> - Hashing</li><br>
46+
<li><!--<a href="https://github.com/HarryDulaney/java-programming-daniel-liang-10th/tree/master/src/">--><strong>Chapter 28</strong><!--</a>--> - Graphs and Applications</li><br>
47+
<li><!--<a href="https://github.com/HarryDulaney/java-programming-daniel-liang-10th/tree/master/src/">--><strong>Chapter 29</strong><!--</a>--> - Weighted Graphs and Applications </li><br>
48+
<li><!--<a href="https://github.com/HarryDulaney/java-programming-daniel-liang-10th/tree/master/src/">--><strong>Chapter 30</strong><!--</a>--> - Multithreading and Parallel Programming</li><br>
49+
<li><!--<a href="https://github.com/HarryDulaney/java-programming-daniel-liang-10th/tree/master/src/">--><strong>Chapter 31</strong><!--</a>--> - Networking </li><br>
50+
<li><!--<a href="https://github.com/HarryDulaney/java-programming-daniel-liang-10th/tree/master/src/">--><strong>Chapter 32</strong><!--</a>--> - Java Database Programming</li><br>
51+
<li><!--<a href="https://github.com/HarryDulaney/java-programming-daniel-liang-10th/tree/master/src/">--><strong>Chapter 33</strong><!--</a>--> - Java Server Faces</li><br>
5552
</ul>

src/ch_03/E0315.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public class E0315 {
2525
public static void main(String[] args) {
2626

2727
int lottery = (int) (Math.random() * 1000);
28-
// int lottery = 174; Test
28+
// int lottery = 174; Test_E2501
2929
Scanner input = new Scanner(System.in);
3030
System.out.print("Enter your lottery pick as an integer of three digits: ");
3131

@@ -35,7 +35,7 @@ public static void main(String[] args) {
3535
int l2 = lottery % 100;
3636
int l3 = l2 / 10;
3737
l2 %= 10;
38-
// Test
38+
// Test_E2501
3939
System.out.println("l1 = " + l1);
4040
System.out.println("l2 = " + l2);
4141
System.out.println("l3 = " + l3);
@@ -44,7 +44,7 @@ public static void main(String[] args) {
4444
int g2 = guess % 100;
4545
int g3 = g2 / 10;
4646
g2 %= 10;
47-
// Test
47+
// Test_E2501
4848
System.out.println("g1 = " + g1);
4949
System.out.println("g2 = " + g2);
5050
System.out.println("g3 = " + g3);

src/ch_03/E0322.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* less than or equal to 10. The formula for computing the distance is 2(x2 -
1515
* x1)2 + (y2 - y1)2.
1616
* <p>
17-
* (Test your program to cover all cases.) <br>
17+
* (Test_E2501 your program to cover all cases.) <br>
1818
* Two sample runs are
1919
* shown below.
2020
* </p>

src/ch_03/E0323.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* (6, 4) is outside the rectangle, as shown in Figure 3.7b.
1212
* <p>
1313
* (Hint: A point is in the rectangle if its horizontal distance to (0, 0) is less than or equal to 10 / 2 and its
14-
* vertical distance to (0, 0) is less than or equal to 5.0 / 2. Test your program to cover all cases.)
14+
* vertical distance to (0, 0) is less than or equal to 5.0 / 2. Test_E2501 your program to cover all cases.)
1515
* <p>
1616
* Here are two sample runs.
1717
* <p>

src/ch_03/E0328.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* the user to enter the center x-, y-coordinates, width, and
88
* height of two rectangles and determines whether the second
99
* rectangle is inside the first or overlaps with the first, as shown
10-
* in Figure 3.9. Test your program to cover all cases.
10+
* in Figure 3.9. Test_E2501 your program to cover all cases.
1111
*
1212
* @author Harry Dulaney
1313
*/

src/ch_03/E0329.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* (Hint: circle2 is inside circle1 if the distance between the two centers <= |r1 - r2|
1111
* and circle2 overlaps circle1 if the distance between the two centers <= r1 + r2.
1212
* <p>
13-
* Test your program to cover all cases.)
13+
* Test_E2501 your program to cover all cases.)
1414
* <p>
1515
* <p>
1616
* Enter circle1's center x-, y-coordinates, and radius: 0.5 5.1 13

src/ch_05/E0502.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public static void main(String[] args) {
4747

4848

4949
System.out.println("Correct Count is " + correctCount +
50-
"\nTest time is " + testTime / 1000 + " seconds\n" + output);
50+
"\nTest_E2501 time is " + testTime / 1000 + " seconds\n" + output);
5151

5252
}
5353
}

src/ch_07/E0706.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public static void main(String[] args) {
2323
while (count < NUMBER_OF_PRIMES) {
2424
// Assume the number is prime
2525
boolean isPrime = true; // Is the current number prime?
26-
// Test whether number is prime
26+
// Test_E2501 whether number is prime
2727
for (int divisor = 2; divisor <= number / 2; divisor++) {
2828
if (number % divisor == 0) { // If true, number is not prime
2929
isPrime = false; // Set isPrime to false

src/ch_07/E0712.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ public class E0712 {
1717
public static void main(String[] args) {
1818
int[] test = new int[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20};
1919
int[] t1 = new int[10];
20-
System.out.println("Test array is: " + Arrays.toString(test));
20+
System.out.println("Test_E2501 array is: " + Arrays.toString(test));
2121
reverse(test);
22-
System.out.println("Test array reversed: " + Arrays.toString(test) + "\n");
22+
System.out.println("Test_E2501 array reversed: " + Arrays.toString(test) + "\n");
2323
System.out.println("Enter 10 numbers: ");
2424
Scanner in = new Scanner(System.in);
2525
for (int i = 0; i < 10; i++) {

src/ch_08/E0807.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* *8.7 (Points nearest to each other) Listing 8.3 gives a program that finds
66
* two points in a two-dimensional space nearest to each other. Revise the
77
* program so that it finds two points in a three-dimensional space nearest to
8-
* each other. Use a two-dimensional array to represent the points. Test the
8+
* each other. Use a two-dimensional array to represent the points. Test_E2501 the
99
* program using the following points: double[][] points = {{-1, 0, 3}, {-1, -1,
1010
* -1}, {4, 1, 1}, {2, 0.5, 9}, {3.5, 2, -1}, {3, 1.5, 3}, {-1.5, 4, 2}, {5.5,
1111
* 4, -0.5}};

src/ch_17/E1706.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public static void main(String[] args) {
5252
}
5353

5454
/**
55-
* Test loan objects boolean.
55+
* Test_E2501 loan objects boolean.
5656
*
5757
* @param loans the loans
5858
* @param file the file

src/ch_25/AbstractTree.java

+18-20
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,29 @@
11
package ch_25;
22

33

4-
public abstract class AbstractTree<E> implements Tree<E>{
4+
public abstract class AbstractTree<E> implements Tree<E> {
55

66

7-
@Override
8-
public void inorder() {
9-
10-
}
7+
@Override
8+
public void inorder() {
119

12-
@Override
13-
public void postorder() {
14-
15-
}
10+
}
1611

17-
@Override
18-
public void preorder() {
19-
20-
}
12+
@Override
13+
public void postorder() {
2114

15+
}
16+
17+
@Override
18+
public void preorder() {
19+
20+
}
21+
22+
23+
@Override
24+
public boolean isEmpty() {
25+
return getSize() == 0;
26+
}
2227

23-
@Override
24-
public boolean isEmpty() {
25-
return getSize() == 0;
26-
}
27-
28-
29-
3028

3129
}

src/ch_25/BST.java

-62
This file was deleted.

src/ch_25/E2501.java

-21
This file was deleted.

0 commit comments

Comments
 (0)