Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed AVL building method - needed to add tree initialization.

  • Loading branch information...
commit 12879c6b43a140783fb21c743366af812d825752 1 parent a24f0bc
@oryband authored
Showing with 10 additions and 4 deletions.
  1. +10 −4 data_structures/assignment_5/FlightManager.java
View
14 data_structures/assignment_5/FlightManager.java
@@ -91,13 +91,19 @@ private int reverse(int n) {
int l = ids.length,
al = l/3;
+ // Init trees.
AvlTree[] trees = new AvlTree[al];
+ int i;
+ for (i=0; i<al; i++) {
+ trees[i] = new AvlTree();
+ }
- // Build tree.
- int i, slot;
+ // Build trees;
+ int id, slot;
for (i=0 ; i<l; i++) {
- slot = hash1(ids[i], l);
- trees[slot].insert(ids[i]);
+ id = ids[i];
+ slot = hash1(id, l);
+ trees[slot].insert(id);
}
// Print row 1 - Trees' height and size.
Please sign in to comment.
Something went wrong with that request. Please try again.