You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Ch. 33.1 and 33.2 for an introduction to segment intersection.
@@ -67,12 +69,24 @@ in $O(log(n))$ time.
67
69
As usual, this project contains a programming part and a testing part.
68
70
You are expected to test your code locally as you develop the program.
69
71
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)
72
75
* We have included a small test case in the support code to get you started.
73
76
74
77
## Student Support Code and Task Description
75
78
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
+
76
90
```
77
91
.
78
92
├── SegmentIntersection.iml
@@ -83,6 +97,7 @@ You are expected to test your code locally as you develop the program.
83
97
│ ├── Driver.java
84
98
│ ├── GUI.java
85
99
│ ├── LineSegment.java
100
+
│ ├── Node.java
86
101
│ ├── OrderedSet.java
87
102
│ └── Sweeper.java
88
103
└── test
@@ -93,18 +108,12 @@ Implementations of the GUI and the Line Sweep Algorithm are provided
93
108
to you in full in the
94
109
[student support code](https://github.com/IUDataStructuresCourse/segment-intersection-student-support-code).
95
110
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.
102
111
103
112
The `BinarySearchTree` class is an elaboration of the class described in
104
113
lecture and that you used in the [NextPrevTree Lab](./NextPrevTree.html).
105
114
The `AVLTree` class is a subclass of `BinarySeachTree` and
106
115
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).
108
117
109
118
Below is a summary of the components in the code base.
110
119
However, before you begin writing any code, you need to understand the
@@ -121,16 +130,18 @@ you should look.
121
130
are used by the Line Sweep Algorithm to determine the line segments
122
131
that are immediately above or below the current segment.
123
132
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
+
124
139
*`BinarySearchTree`**[YOUR TASK]** is a generic class corresponding
125
140
to a binary search tree. The ordering for the data in the tree
126
141
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
128
143
`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.
134
145
135
146
*`AVLTree`**[YOUR TASK]** is a class representing a height-balanced tree. Since
136
147
`AVLTree` is a subclass of `BinarySearchTree`, you will need a fully
@@ -139,7 +150,7 @@ you should look.
139
150
important part of this entire project, so make sure you allow
140
151
yourself enough time to work on it.
141
152
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
143
154
immediately available to us whenever we need it.
144
155
This means that when a new node is inserted or removed from the tree,
145
156
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`.
167
178
Algorithm. Be sure to read through this code to help you understand
168
179
how the algorithm works.
169
180
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
+
170
189
-----------------
171
190
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