bit

package
v0.2.12 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 30, 2021 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BIT

type BIT struct {
	// contains filtered or unexported fields
}

func NewBIT

func NewBIT(size int) *BIT

NewBIT returns an object representing Binary Index Tree or Fenwick Tree of given size.

func (*BIT) Len

func (this *BIT) Len() int

Len returns the size of the BIT. Complexity - O(1).

func (*BIT) Query

func (this *BIT) Query(index int) int

Query returns a sum of first [0...index] elements of Binary Index Tree. Complexity - O(LogN).

func (*BIT) Update

func (this *BIT) Update(index, val int)

Update updates a node in Binary Index Tree (BIT) at given index in BIT. The given value `val` is added to BIT[i] and all of its ancestors in tree. Complexity - O(LogN).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL