This repository has been archived by the owner on Dec 28, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #202 from polis-vk/homework7
Homework 7
- Loading branch information
Showing
4 changed files
with
489 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
src/main/java/company/vk/polis/ads/bst/RedBlackBinarySearchTree.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
package company.vk.polis.ads.bst; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
/** | ||
* LLRB implementation of binary search tree. | ||
*/ | ||
public class RedBlackBinarySearchTree<Key extends Comparable<Key>, Value> | ||
implements BinarySearchTree<Key, Value> { | ||
|
||
private static final boolean BLACK = false; | ||
private static final boolean RED = true; | ||
|
||
private class Node { | ||
Key key; | ||
Value value; | ||
Node left; | ||
Node right; | ||
boolean color; | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public Value get(@NotNull Key key) { | ||
throw new UnsupportedOperationException("Implement me"); | ||
} | ||
|
||
@Override | ||
public void put(@NotNull Key key, @NotNull Value value) { | ||
throw new UnsupportedOperationException("Implement me"); | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public Value remove(@NotNull Key key) { | ||
throw new UnsupportedOperationException("Implement me"); | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public Key min() { | ||
throw new UnsupportedOperationException("Implement me"); | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public Value minValue() { | ||
throw new UnsupportedOperationException("Implement me"); | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public Key max() { | ||
throw new UnsupportedOperationException("Implement me"); | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public Value maxValue() { | ||
throw new UnsupportedOperationException("Implement me"); | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public Key floor(@NotNull Key key) { | ||
throw new UnsupportedOperationException("Implement me"); | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public Key ceil(@NotNull Key key) { | ||
throw new UnsupportedOperationException("Implement me"); | ||
} | ||
|
||
@Override | ||
public int size() { | ||
throw new UnsupportedOperationException("Implement me"); | ||
} | ||
|
||
/** | ||
* Только для тестов | ||
* Саму высоту хранить не обязательно, достаточно сделать рекурсивное вычисление | ||
*/ | ||
@Override | ||
public int height() { | ||
throw new UnsupportedOperationException("Implement me"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.