Skip to content

Commit b3ce379

Browse files
committed
2 parents 37e0cf5 + 0868a24 commit b3ce379

File tree

1 file changed

+37
-18
lines changed

1 file changed

+37
-18
lines changed

SegmentIntersection.md

+37-18
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55

66
## Before We Start (Optional)
77

8-
+ Read Textbook Ch. 4.4 carefully, especially the code listings
8+
+ Review [lecture notes](./lectures/binary-search-trees.md) for binary search trees.
9+
(**HINT:** this will make writing `BinarySearchTree` really easy)
10+
+ Read Textbook Ch. 4.4 carefully, ***especially*** the code listings
911
from Fig. 4.37 to Fig. 4.44.
1012
+ Read [CLRS](http://mitpress.mit.edu/9780262046305/introduction-to-algorithms/)
1113
Ch. 33.1 and 33.2 for an introduction to segment intersection.
@@ -67,12 +69,24 @@ in $O(log(n))$ time.
6769
As usual, this project contains a programming part and a testing part.
6870
You are expected to test your code locally as you develop the program.
6971

70-
+ Submit your code `AVLTree.java` and `BinarySearchTree.java` to the autograder SegmentIntersection project.
71-
+ Submit your test cases `StudentTest.java` to the autograder SegmentIntersectionTest project.
72+
<!-- TODO: Link AG -->
73+
+ Submit your code `AVLTree.java` and `BinarySearchTree.java` to the autograder SegmentIntersection project [here](https://autograder.luddy.indiana.edu/web/project/1530)
74+
+ Submit your test cases `StudentTest.java` to the autograder SegmentIntersectionTest project [here](https://autograder.luddy.indiana.edu/web/project/1529)
7275
* We have included a small test case in the support code to get you started.
7376

7477
## Student Support Code and Task Description
7578

79+
Your task is to complete the implementation of the
80+
`BinarySearchTree` and `AVLTree` class.
81+
⚠️**You are NOT supposed to modify any code outside the two classes**
82+
(marked as "read-only" in the project structure below).
83+
Implement all of the methods marked `TODO` according to their descriptions
84+
in the comments. **DO NOT** change their function signatures.
85+
86+
87+
88+
### Student Support Code [[🔗 link](https://github.com/IUDataStructuresCourse/segment-intersection-student-support-code)]
89+
7690
```
7791
.
7892
├── SegmentIntersection.iml
@@ -83,6 +97,7 @@ You are expected to test your code locally as you develop the program.
8397
│   ├── Driver.java
8498
│   ├── GUI.java
8599
│   ├── LineSegment.java
100+
│ ├── Node.java
86101
│   ├── OrderedSet.java
87102
│   └── Sweeper.java
88103
└── test
@@ -93,18 +108,12 @@ Implementations of the GUI and the Line Sweep Algorithm are provided
93108
to you in full in the
94109
[student support code](https://github.com/IUDataStructuresCourse/segment-intersection-student-support-code).
95110

96-
Your task is to complete the implementation of the
97-
`BinarySearchTree` and `AVLTree` class.
98-
⚠️**You are NOT supposed to modify any code outside the two classes**
99-
(marked as "read-only" in the project structure below).
100-
Implement all of the methods marked `TODO` according to their descriptions
101-
in the comments. **DO NOT** change their function signatures.
102111

103112
The `BinarySearchTree` class is an elaboration of the class described in
104113
lecture and that you used in the [NextPrevTree Lab](./NextPrevTree.html).
105114
The `AVLTree` class is a subclass of `BinarySeachTree` and
106115
overrides the `insert()` and `remove()` methods to ensure that the tree remains
107-
balanced at all times (which gives us the $O(log(n)$) time bound we crave).
116+
balanced at all times (which gives us the $O(log(n))$ time bound we crave).
108117

109118
Below is a summary of the components in the code base.
110119
However, before you begin writing any code, you need to understand the
@@ -121,16 +130,18 @@ you should look.
121130
are used by the Line Sweep Algorithm to determine the line segments
122131
that are immediately above or below the current segment.
123132

133+
* `Node` [read-only] is a class implementing the `Location` interface.
134+
A `Node` contains the usual fields: `key`, `left`, and `right`, as well as
135+
two more fields: `parent` (which points to the node's parent in the
136+
tree) and `height` (which is the height of the subtree rooted at
137+
this node).
138+
124139
* `BinarySearchTree` **[YOUR TASK]** is a generic class corresponding
125140
to a binary search tree. The ordering for the data in the tree
126141
is specified by a function of type `BiPredicate` and provided at
127-
construction time. Nodes in the tree are represented by the inner
142+
construction time. Nodes in the tree are represented by the
128143
`Node` class. So that we can use `Node` as a return value from
129-
`search()`, `Node` implements the `Location` interface. A `Node`
130-
contains the usual fields: `key`, `left`, and `right`. You will add
131-
two more fields: `parent` (which points to the node's parent in the
132-
tree) and `height` (which is the height of the subtree rooted at
133-
this node).
144+
`search()`, `Node` implements the `Location` interface.
134145

135146
* `AVLTree` **[YOUR TASK]** is a class representing a height-balanced tree. Since
136147
`AVLTree` is a subclass of `BinarySearchTree`, you will need a fully
@@ -139,7 +150,7 @@ you should look.
139150
important part of this entire project, so make sure you allow
140151
yourself enough time to work on it.
141152

142-
We can maintain the height information in the tree nodes so that it is
153+
We maintain the height information in the tree nodes so that it is
143154
immediately available to us whenever we need it.
144155
This means that when a new node is inserted or removed from the tree,
145156
we may have to adjust the heights of the nodes along the path up to the root.
@@ -167,6 +178,14 @@ The root has no parent so its parent is `null`.
167178
Algorithm. Be sure to read through this code to help you understand
168179
how the algorithm works.
169180

181+
### Troubleshooting
182+
183+
Here are a few common issues and things to rememer as you complete the project 🙂
184+
- Remember that you need to update `parent` pointers for nodes, as well as `left` and `right` as you normally would
185+
- Remember to call `updateHeight` on nodes whenever their children change.
186+
- Both `BinarySearchTree` and `AVLTree` are responsible for maintaining the `numNodes` variable to track the size of the tree.
187+
188+
170189
-----------------
171190

172-
* You have finally reached the end of the Project. Congratulations!
191+
* You have finally reached the end of the project. Congratulations!

0 commit comments

Comments
 (0)