Skip to main content

Segment Tree package written in C

Project description

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)

Project details


Release history Release notifications | RSS feed

This version

1.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

c-segment-tree-1.0.tar.gz (18.4 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page