Segment tree & Fenwick tree
Në shqip: Pema e segmenteve
ShpjegimiSQ
Pema e segmenteve dhe pema Fenwick ruajnë informacion për copa të një liste, që t'u përgjigjen shpejt pyetjeve si „sa është shuma nga pozicioni 3 te 8?“ edhe kur lista ndryshon shpesh — të dyja në O(log n). Shumë të përdorura në gara.
EnglishEN
Segment trees and Fenwick trees store information about slices of a list, to quickly answer questions like “what's the sum from position 3 to 8?” even when the list changes often — both in O(log n). Widely used in contests.
Si ta mendosh
Si raportet e shitjeve: për çdo ditë, javë dhe muaj — që të mos i mbledhësh të gjitha faturat nga e para çdo herë.
Lexoje në anglisht
Like sales reports by day, week and month — so you don't add up every receipt from scratch each time.