Line segment tree and weighted line segment tree

Line tree

The line segment tree is essentially a binary search tree, which divides the original array into segments of space and builds a tree through certain relationships. It is different from the binary tree. The binary tree data is not related to each other, while the line segment tree is essentially an array expanded from the original array. The data is related to each other, so it can perform operations and access modifications under certain line segment associativity.

Time complexity changed from O(n) or O(n^2) to O(logn) or O(n logn)

Weighted segment tree

The weighted line segment tree is a special type of line segment tree. The weights stored in it refer to the number of times the value range appears in the interval. In some specific problems can be quickly searched.
Mainly used to find the nth largest/smallest application.

Guess you like

Origin blog.csdn.net/qq_53737964/article/details/113138634