Skip to main content

Segment Tree written in C as a Python Module

This is a Segment Tree written in C, made available as a Python package.

It supports basic min/max/sum queries which all happen in log(n) time. It also supports update queries in log(n) time.

Usage Examples

> from segtree import Segtree
> obj = Segtree([1, 2, 3, 4, 5], 'sum') # Accepted types: 'sum', 'min', 'max
> obj.sum(0, 3)                         # Gets range sum in log(n) time
> obj.update(0, 50)                     # Updates index 0 to value 50 in log(n) time
> from segtree import Segtree
> obj = Segtree([1, 2, 3, 4, 5], 'min')
> obj.min(0, 3)
> obj.update(0, 50)
> from segtree import Segtree
> obj = Segtree([1, 2, 3, 4, 5], 'max')
> obj.max(0, 3)
> obj.update(0, 50)

Metadata

Release files for c-segment-tree 1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for c-segment-tree 1.0
File Size Uploaded
c-segment-tree-1.0.tar.gz 18.4 kB Details

Release files / c-segment-tree-1.0.tar.gz

Download URL c-segment-tree-1.0.tar.gz
Size 18.4 kB
Tags Source
SHA-256 checksum
How to use checksums
95c66ddade697885fbb4f9e5b0d8cdc1ea08749a8eba9573eb51c2a0253903f5
BLAKE2b-256 checksum
How to use checksums
a0a9b13fcd3f2b2a6a465c9fe4381d5ef453147a9e03960bcebebf4f91949c38
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

Release history Release notifications | RSS feed

This release

1.0 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page