Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
a2660e0
Setting up GitHub Classroom Feedback
github-classroom[bot] Mar 18, 2024
90aca06
Create LICENSE
sofyak0zyreva Mar 23, 2024
7acaadf
feat: create project with gradle
p1onerka Mar 23, 2024
7ec4502
Merge pull request #2 from spbu-coding-2023/dev-Ksenia
p1onerka Mar 23, 2024
d3a9c1a
feat: implement abstract node and abstract tree
p1onerka Mar 23, 2024
0e6b28d
Merge pull request #3 from spbu-coding-2023/dev-Ksenia
p1onerka Mar 23, 2024
2b324f6
feat: implement AVL node
sofyak0zyreva Mar 23, 2024
c62e07f
feat: implement balanced tree class with rotation methods
p1onerka Mar 23, 2024
494610a
Merge pull request #4 from spbu-coding-2023/dev-Ksenia
p1onerka Mar 23, 2024
1065532
Merge remote-tracking branch 'origin/main' into dev-SoniaK
sofyak0zyreva Mar 23, 2024
27060f4
feat: implement AVL tree and override methods(insert and delete); imp…
sofyak0zyreva Mar 23, 2024
137c15b
feat(AVL): implement balancing methods for the tree
sofyak0zyreva Mar 23, 2024
e7f81ec
feat(BST): implement binary search tree and its node
p1onerka Mar 24, 2024
373f581
fix(abstractNode): change key from var to val
p1onerka Mar 25, 2024
9279abe
feat(abstractTree): add traverse method into abstractTree class
p1onerka Mar 25, 2024
3f48c93
Merge pull request #5 from spbu-coding-2023/dev-Ksenia
p1onerka Mar 25, 2024
e8080f2
fix(AVL&balancedTree): implement 1 balance method instead of 2
sofyak0zyreva Mar 25, 2024
fcb8027
Merge pull request #6 from spbu-coding-2023/dev-SoniaK
sofyak0zyreva Mar 25, 2024
f58d47c
feat(RBT): implement node of red_black tree
shvorobsofia Mar 27, 2024
9038eed
feat(RBT): : implementred-black tree and his methods getUncle, getSib…
shvorobsofia Mar 27, 2024
afc796d
fix(abstractTree): make findMinNodeInRight and findNodeByKey protecte…
sofyak0zyreva Mar 27, 2024
4d16b45
fix(AVL): refactor delete method for different cases (no/1/2 children)
sofyak0zyreva Mar 27, 2024
5eb8779
Merge pull request #7 from spbu-coding-2023/dev-SoniaS
shvorobsofia Mar 28, 2024
12bd2ea
fix(abstractTree): change return values in deleteNode
sofyak0zyreva Mar 28, 2024
a0b03cd
feat(AVL): implement preorderTraverse
sofyak0zyreva Mar 28, 2024
b379eec
Merge pull request #8 from spbu-coding-2023/dev-SoniaK
sofyak0zyreva Mar 28, 2024
d8cd6f8
feat(CI): add first version of CI via GitHub actions
p1onerka Mar 29, 2024
844b7cf
feat(CI): add build check to CI
p1onerka Mar 29, 2024
9212f82
feat(CI): add autotests run to CI
p1onerka Mar 30, 2024
12323d3
feat(CI): add jacoco plugin for test coverage control
p1onerka Mar 30, 2024
ec65704
Add CI via GitHub Actions
p1onerka Mar 30, 2024
47c8258
fix(abstraction): move preorderTraverse method to BSTree class and ma…
p1onerka Mar 30, 2024
897a6ca
fix(abstraction): refactor of abstractTree class
p1onerka Mar 30, 2024
e91d39a
Refactor abstraction and BSTree
p1onerka Mar 30, 2024
134bf27
fix(CI): move CI.yml to workflows directory
p1onerka Mar 30, 2024
8a481ad
Move CI.yml to workflows directory
p1onerka Mar 30, 2024
cc9309e
feat(AVL): implement private getNumberOfChildren method and change de…
sofyak0zyreva Mar 30, 2024
e2b7ab5
feat(RBT): implement method of insertion
shvorobsofia Mar 28, 2024
ab60a5d
feat(RBT): Implement method balance and signature of methods balanceA…
shvorobsofia Mar 30, 2024
22fbc42
feat(RBT): Impement method balanceAfterInsert
shvorobsofia Mar 30, 2024
4f36ef0
feat(RBT): Implemet methods of deleting a node (with 6 cases of delit…
shvorobsofia Mar 30, 2024
5f68472
feat(RBT): Implement method preorderTraverse
shvorobsofia Mar 30, 2024
2d8a878
Merge pull request #12 from spbu-coding-2023/dev-SoniaS
shvorobsofia Mar 30, 2024
d5cae7f
fix(RBT): Implement class of red-black nodes
shvorobsofia Mar 30, 2024
679200e
fix(RBT): Delete prints, change mention of methode moveParentNode to …
shvorobsofia Mar 30, 2024
c23e6bc
fix(build.gradle): fix dependencies
sofyak0zyreva Mar 30, 2024
30e54b9
feat(AVLTest): implement tests for avl tree
sofyak0zyreva Mar 30, 2024
5e7169b
Merge pull request #13 from spbu-coding-2023/dev-SoniaK
sofyak0zyreva Mar 30, 2024
cdda702
fix(AVL&RB): change package directive to match the file location; sma…
sofyak0zyreva Mar 30, 2024
700b945
Merge pull request #14 from spbu-coding-2023/dev-SoniaK
sofyak0zyreva Mar 30, 2024
b9de719
feat(BST): implement first pack of tests for BST
p1onerka Mar 30, 2024
48236b3
Create README.md
sofyak0zyreva Mar 30, 2024
5922a2d
feat(RBT): Implement tests for a red-black tree
shvorobsofia Mar 31, 2024
a11a7a2
feat(RBT): Implement tests for a red-black tree
shvorobsofia Mar 31, 2024
31b3784
Merge pull request #17 from spbu-coding-2023/dev-SoniaS
shvorobsofia Mar 31, 2024
34428f2
fix(BST): change packages configuration in BSTreeTest for uniformity
p1onerka Mar 31, 2024
7531012
fix(BST): add exception, the need for which was identified during tes…
p1onerka Mar 31, 2024
f00a0ea
Implement BSTree tests
p1onerka Mar 31, 2024
0366900
fix(AVLTest): beautify the code, add @BeforeEach
sofyak0zyreva Apr 7, 2024
79eacc0
fix(AVL): reformat the code
sofyak0zyreva Apr 7, 2024
3b91509
Merge pull request #18 from spbu-coding-2023/dev-SoniaK
sofyak0zyreva Apr 7, 2024
8ecfeff
fix(RBT): remove separate cases for balanceAfterDelete as they create…
shvorobsofia Apr 7, 2024
97a20de
fix(RBT): fix code formatting
shvorobsofia Apr 7, 2024
ed22015
fix(RBTreeTest): beautify the code, add @beforeeach
shvorobsofia Apr 7, 2024
cdd6a72
Merge pull request #19 from spbu-coding-2023/dev-SoniaS
shvorobsofia Apr 7, 2024
5aeb6e6
fix(Abstractions): refactor code to fit it in kotlin coding conventions
p1onerka Apr 7, 2024
002bed3
fix(BSTreeTest): optimize test code by using BeforeEach
p1onerka Apr 7, 2024
ff95940
Perform a post-review refactoring
p1onerka Apr 7, 2024
0320520
fix: add files to .gitignore
sofyak0zyreva Apr 7, 2024
8e1a5f7
Merge pull request #21 from spbu-coding-2023/dev-SoniaK
sofyak0zyreva Apr 7, 2024
6a57f50
fix(configuration): delete .idea files from project
p1onerka Apr 7, 2024
659a2ab
Delete .idea files
p1onerka Apr 7, 2024
786e7a9
fix(AbstractTree): change unnecessary "when"-s to "if"-s
p1onerka Apr 11, 2024
f4eb2a9
fix(AbstractTree): small change of comments and exceptions messages
p1onerka Apr 11, 2024
7266f7b
Beautify AbstractTree class
p1onerka Apr 11, 2024
3be9606
Update README.md
sofyak0zyreva Apr 11, 2024
96510da
fix(tests): full post-review change of tests architecture. Optimizati…
p1onerka Apr 15, 2024
91d7ef3
Change the tests arch
p1onerka Apr 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: CI

on:
push:
pull_request:
branches: [ "main" ]

jobs:
Tests:
runs-on: ubuntu-latest

steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'

- name: Setup Gradle
uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5

- name: Build with Gradle Wrapper
run: ./gradlew build

- name: Run autotests
run: ./gradlew test

- name: Run Test Coverage
run: ./gradlew jacocoTestReport
44 changes: 44 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
.gradle
build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/

### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr
out/
!**/src/main/**/out/
!**/src/test/**/out/

### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/

### VS Code ###
.vscode/

### Mac OS ###
.DS_Store
/lib/src/main/resources/
/.idea/
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Ksenia Kotelnikova, Sofya Kozyreva, Sofia Shvorob

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
72 changes: 72 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
## About the project

This library allows you to use three types of binary search trees: simple, AVL and Red-Black tree. [AVL](https://en.wikipedia.org/wiki/AVL_tree) and [Red-Black](https://en.wikipedia.org/wiki/Red–black_tree) tree implement their natural balancing.

## Getting started
1. Download our lib from [Releases](https://github.com/spbu-coding-2023/trees-5/releases)
2. Open your project
3. Go to `File > New > Module from Existing Sources...`
4. Choose the lib you downloaded
5. Add this in your program:

```
import trees.*
```
You can replace `*` with any specific tree

## How to use
There are 4 public methods you can use for each tree:

* `insert(key, value)` inserts a node with such key and value. If a node with the same key already exists in the tree, old value is replaced with the new one. Note that key should be of Comparable type.
* `delete(key)` deletes a node with such key. If there is no node with that key, nothing is done.
* `find(key)` finds a node with such key and returns its value. If there is no node with that key, null is returned.
* `preorderTraverse()` traverses the tree recursively from `parent` to `left child` to `right child` (specific for every tree)

Now you can simply create a tree: `BSTree`, `AVLTree` or `RBTree`:
```
val tree = RBTree<Int, String>()
```
Start inserting and deleting nodes:
```
tree.insert(11, "Welcome to the jungle")
tree.insert(9, "We got fun and games")
tree.insert(27, "We take it day by day")
tree.delete(11)
val value1 = find(9) // value = "We got fun and games"
val value2 = find(15) // value = null
```
Here are some examples for traversing each tree:

For `BSTree` it saves node's key:
```
val bstree = BSTree<Int, String>()
bstree.insert(99, "Empty spaces")
bstree.insert(88, "What are we living for?")
bstree.insert(77, "Abandonded places")
val myList = bstree.preorderTraverse() // myList = [99, 88, 77]
```
For `AVLTree` it saves node's key and height:
```
val avltree = AVLTree<Int, String>()
avltree.insert(11, "When you were here before")
avltree.insert(1, "Couldn't look you in the eye")
avltree.insert(111, "You're just like an angel")
val myList = avltree.preorderTraverse() // myList = [(11, 2), (1, 1), (111, 1)]
```
For `RBTree` it saves node's key and color:
```
val rbtree = RBTree<Int, String>()
rbtree.insert(30, "...we built this house")
rbtree.insert(20, "On memories")
rbtree.insert(25, "Take my picture now")
val myList = rbtree.preorderTraverse() // myList = [(25, BLACK), (20, RED), (30, RED)]
```

Have fun!
## Developers and contacts
* [p1onerka](https://github.com/p1onerka) (tg @p10nerka)
* [sofyak0zyreva](https://github.com/sofyak0zyreva) (tg @soffque)
* [shvorobsofia](https://github.com/shvorobsofia) (tg @fshv23)

## License
The product is distributed under MIT license. Check LICENSE for more information
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
kotlin.code.style=official
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
6 changes: 6 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#Sat Mar 23 16:46:44 MSK 2024
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading