Help us shape the future of Go! Take the 2026 Go Developer Survey

treenums

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2022 License: GPL-3.0 Imports: 0 Imported by: 0

README

  1. t[x]父节点 = t[x+lowbit(x)]
  2. t[x]前一个兄弟节点 = t[x-lowbit(x)]

add

image-20220404125648385

ask

image-20220404125724645

区间修改,区间查询

image-20220404133852101

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TreeNum

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

func NewTreeNum

func NewTreeNum(n int) *TreeNum

NewTreeNum 初始化一个存储n个元素的树状数组

func (*TreeNum) Add

func (t *TreeNum) Add(x, d int)

Add x点值+d;x = [0,n-1]

func (*TreeNum) Ask

func (t *TreeNum) Ask(x int) (ret int)

Ask 查询x下标处的前缀和;x = [0,n-1]

Jump to

Keyboard shortcuts

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