2020-06-26 21:12:04 +00:00
---
id: seg-ext
title: "More Applications of Segment Tree"
author: Benjamin Qi
prerequisites:
- Gold - Static Range Queries
- Gold - Point Update Range Query
description: "?"
frequency: 3
---
import { Problem } from "../models";
export const metadata = {
problems: {
walkSam: [
new Problem("CSES", "Hotel Queries", "1143", "Easy", false, ["PURQ"], "walk"),
],
walk: [
new Problem("Old Gold", "Seating", "231", "Normal", false, [], "walk on max segtree"),
new Problem("Plat", "Balancing", "624", "Normal", false, [], "walk"),
],
combSam: [
new Problem("CSES", "Subarray Sum Queries", "1190", "Normal", false, ["PURQ"], "comb"),
],
comb: [
2020-06-30 20:25:02 +00:00
new Problem("Old Gold", "Marathon", "495", "Easy", false, [], "comb"),
2020-06-26 21:12:04 +00:00
new Problem("Old Gold", "Optimal Milking", "365", "Normal", false, [], "comb"),
2020-06-30 20:25:02 +00:00
new Problem("POI", "Cards", "https://szkopul.edu.pl/problemset/problem/qpsk3ygf8MU7D_1Es0oc_xd8/site/?key=statement", "Normal", false, [], "comb"),
new Problem("Plat", "High Card Low Card", "577", "Normal", false, ["PURQ", "Greedy"], "comb"),
2020-06-26 21:12:04 +00:00
],
waveletSam: [
2020-06-30 20:25:02 +00:00
new Problem("YS", "Range K-th Smallest", "range_kth_smallest", "Normal", false, ["Wavelet"], ""),
2020-06-26 21:12:04 +00:00
],
wavelet: [
new Problem("Kattis", "Easy Query", "easyquery", "Hard", false, ["Wavelet"], ""),
new Problem("DMOJ", "Ninjaclasher's Wrath 2", "globexcup19s4", "Hard", false, ["Wavelet"], ""),
],
}
};
## Walking on a Segment Tree
<problems-list problems={metadata.problems.walkSam} />
You want to support queries of the following form on an array $a_1,\ldots,a_N$ (along with point updates).
> Find the first $i$ such that $a_i\ge x$.
Of course, you can do this in $O(\log^2N)$ time with a max segment tree and binary searching on the first $i$ such that $\max(a_1,\ldots,a_i)\ge x$. But try to do this in $O(\log N)$ time.
<problems-list problems={metadata.problems.walk} />
## Combining
<problems-list problems={metadata.problems.combSam} />
(solution to above problem)
<problems-list problems={metadata.problems.comb} />
## Wavelet Tree
<problems-list problems={metadata.problems.waveletSam} />
### Tutorial
2020-06-27 00:33:06 +00:00
<resources>
<resource source="CF" title="Intro to New DS: Wavelet Trees" url="blog/entry/52854"></resource>
</resources>
2020-06-26 21:12:04 +00:00
### Problems
<problems-list problems={metadata.problems.wavelet} />