Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
2XB3FinalProject
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Christopher Schankula
2XB3FinalProject
Commits
246ebd57
Commit
246ebd57
authored
6 years ago
by
Christopher Schankula
Browse files
Options
Downloads
Patches
Plain Diff
use quickselect for KDT (failing...)
parent
d9107332
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/sort/KDT.java
+1
-1
1 addition, 1 deletion
src/sort/KDT.java
src/sort/QuickSelect.java
+10
-0
10 additions, 0 deletions
src/sort/QuickSelect.java
with
11 additions
and
1 deletion
src/sort/KDT.java
+
1
−
1
View file @
246ebd57
...
...
@@ -119,7 +119,7 @@ public class KDT<KeyVal extends Comparable<KeyVal>> implements Serializable {
int
axis
=
depth
%
getK
();
int
mid
=
(
lo
+
hi
)
/
2
;
MergeSort
.
sort
(
keyvals
,
lo
,
hi
,
axes
.
get
(
axis
));
QuickSelect
.
median
(
keyvals
,
lo
,
hi
,
axes
.
get
(
axis
));
KeyVal
median
=
(
KeyVal
)
keyvals
[
mid
];
//TODO: fix size
...
...
This diff is collapsed.
Click to expand it.
src/sort/QuickSelect.java
+
10
−
0
View file @
246ebd57
...
...
@@ -30,6 +30,16 @@ public class QuickSelect {
sort
(
a
,
0
,
a
.
length
-
1
,
a
.
length
/
2
,
gc
);
}
/**
* Partially sorts a comparable array such that elements smaller than the median occur in
* the first half of the array, and elements larger than the median occur in the second half
* @param a Array of comparable items
* @param gc Lambda function to compare items
*/
public
static
<
T
>
void
median
(
Comparable
<
T
>[]
a
,
int
lo
,
int
hi
,
GeneralCompare
<
T
>
gc
)
{
sort
(
a
,
lo
,
hi
,
(
hi
-
lo
)
/
2
,
gc
);
}
/**
* Partially sorts a comparable array such that elements smaller than the kth largest element
* occur in the first half of the array, and larger elements occur in the second half
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment