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
44ddd304
Commit
44ddd304
authored
7 years ago
by
Lawrence Chung
Browse files
Options
Downloads
Patches
Plain Diff
RedBlackTree skeleton
parent
16dae32c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/search/RedBlackTree.java
+33
-2
33 additions, 2 deletions
src/search/RedBlackTree.java
with
33 additions
and
2 deletions
src/search/RedBlackTree.java
+
33
−
2
View file @
44ddd304
package
search
;
public
class
RedBlackTree
{
public
class
RedBlackTree
<
Key
,
Value
>
{
private
Node
root
;
private
int
size
();
public
void
put
(
Key
key
,
Value
val
){
root
=
put
(
root
,
key
,
val
);
root
.
color
=
BLACK
;
}
private
Node
put
(
Node
h
,
Key
key
,
Value
val
){
if
(
h
==
null
)
return
new
Node
(
key
,
val
,
1
,
RED
);
int
cmp
=
key
.
compareTo
(
h
.
key
);
if
(
cmp
<
0
)
h
.
left
=
put
(
h
.
left
,
key
,
val
);
else
if
(
cmp
>
0
)
h
.
right
=
put
(
h
.
right
(),
key
,
val
);
else
h
.
val
=
val
;
if
(
isRed
(
h
.
right
)
&&
!
isRed
(
h
.
left
))
h
=
rotateLeft
(
h
);
if
(
isRed
(
h
.
left
)
&&
isRed
(
h
.
left
.
left
))
h
=
rotateRight
(
h
);
if
(
isRed
(
h
.
left
)
&&
isRed
(
h
.
right
))
flipColors
(
h
);
h
.
n
=
size
(
h
.
left
)
+
size
(
h
.
right
)
+
1
;
return
h
;
}
}
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