Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/adrian-lin-1-0-0/go-ds
Go data structures for competitive programming
https://github.com/adrian-lin-1-0-0/go-ds
competitive-programming data-structures go golang
Last synced: 10 days ago
JSON representation
Go data structures for competitive programming
- Host: GitHub
- URL: https://github.com/adrian-lin-1-0-0/go-ds
- Owner: adrian-lin-1-0-0
- License: mit
- Created: 2024-03-03T14:47:30.000Z (11 months ago)
- Default Branch: master
- Last Pushed: 2024-03-07T16:54:49.000Z (11 months ago)
- Last Synced: 2024-11-26T02:22:54.194Z (2 months ago)
- Topics: competitive-programming, data-structures, go, golang
- Language: Go
- Homepage:
- Size: 10.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Go Data Structures
## Tree
```sh
go get github.com/adrian-lin-1-0-0/go-ds/tree@latest
```- [Fenwick tree (Binary Index Tree)](./tree/bit.go)
Time Complexity
| Operation | Average | Worst case |
| ---- | ---- | --- |
| Update | O(log n) | O(log n) |
| Query | O(log n) | O(log n) |
| Range Query | O(log n) | O(log n) |
Space Complexity
| Average | Worst case |
| ---- | --- |
| O(n) | O(n) |```go
package main
import (
"github.com/adrian-lin-1-0-0/go-ds/tree"
)
func main(){
bit := tree.NewBIT[int](10)
bit.Update(1, 1)
bit.Update(2, 2)
bit.Update(3, 3)
bit.Query(3) // 6
bit.RangeQuery(1,2) // 3
}
```