-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add trie #79
base: main
Are you sure you want to change the base?
Add trie #79
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Please use figure to support the explanation and be aware of the resolution. You should put more effort on explanation.
- You may refer to others PR or the article that has been merged into NTHU-CPP to know that what kind of article you have to write.
- https://nthu-cp.github.io/NTHU-CPP/graph/lca.html
- https://nthu-cp.github.io/NTHU-CPP/math/introduction_to_generating_function.html
- https://nthu-cp.github.io/NTHU-CPP/graph/introduction_to_AP_bridge.html
- https://nthu-cp.github.io/NTHU-CPP/graph/introduction_to_BCC.html
- https://nthu-cp.github.io/NTHU-CPP/greedy/basic.html
- https://nthu-cp.github.io/NTHU-CPP/sqrt/sqrt_decomposition.html
- Please rebase to the latest main branch and fix markdownlint and textlint.
- There should be two section
- Example problem: you should explain the problem in detail (including problem description, solution, code, time complexity/correctness analysis...). Also, please solve these problem with your own template code that mention above.
- Exercise problem: a problem list that reader may do if they want to practice treap, you don't have to explain these problem in detail, you may provide hint only.
- Please follow the format.
- You should read more resources and pick the best implementation (clean and fast)
src/data_structure/image/p1.jpg
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The image path should be image/trie/xxx.jpg
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please be consistent about the style of the figure
有了這個樹狀的 Trie,我們可以在節點上儲存一些資訊,在查詢是否存在的這個例子,我們可以在每個節點上 | ||
存一個 `int` 代表目前的字串集合,有幾個字串等於這個節點代表的字串。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
這一段應該在後面查詢再解釋
有了這個樹狀的 Trie,我們可以在節點上儲存一些資訊,在查詢是否存在的這個例子,我們可以在每個節點上 | ||
存一個 `int` 代表目前的字串集合,有幾個字串等於這個節點代表的字串。 | ||
|
||
![](./image/p1.jpg) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
你的文字敘述是邊代表字元
但你圖不是這樣表示啊?
有了這個樹狀的 Trie,我們可以在節點上儲存一些資訊,在查詢是否存在的這個例子,我們可以在每個節點上 | ||
存一個 `int` 代表目前的字串集合,有幾個字串等於這個節點代表的字串。 | ||
|
||
![](./image/p1.jpg) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
圖的解析度有點差
|
||
### 查詢 | ||
|
||
查詢一個字串是否出現在集合中,我們可以從跟節點(空字串)開始,照著要查詢的字串, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
跟->根
src/data_structure/trie.md
Outdated
### 例題: BZOJ1954 樹上最大 xor sum 路徑 | ||
|
||
一棵帶有正整數邊權的無根樹,求 \\((u, v)\\) 使得節點 \\(u\\) 到 \\(v\\) 的路徑之間邊權 xor 總和最大,輸出這個邊權 xor 總和。 (\\(1 \leq N \leq 10^5, 0 \leq w \le 2^31\\)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
題目格式請參考其他文章
src/data_structure/trie.md
Outdated
|
||
## 其他例題 | ||
|
||
### 最大 XOR sum 子陣列 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Problem source?
src/data_structure/trie.md
Outdated
|
||
因此我們同樣可以使用 xor trie 的技巧,先將所有 \\(P(i)\\)加入 xor trie,接著我們枚舉第一個元素 L,我們即可以在 trie 中尋找最大化 \\(P(L) \oplus P(R)\\) 的 R。 | ||
|
||
### First Second |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
problem source?
|
||
### 複雜度分析 | ||
|
||
考慮到每次新增會增加一個長度為 \\(L\\) 所會創造出的節點數還是 \\(O(L)\\),時間複雜度和空間複雜度與一般的 trie 一樣皆是線性於操作的字串長度。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
persistent 資料結構的空間複雜度需要好好分析
不能以單一操作來分析空間複雜度...
- https://oi-wiki.org/string/trie/#%E7%BB%B4%E6%8A%A4%E5%BC%82%E6%88%96%E6%9E%81%E5%80%BC | ||
- https://www.topcoder.com/thrive/articles/Using%20Tries | ||
- https://iq.opengenus.org/persistent-trie/ | ||
- https://codeforces.com/blog/entry/93724 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- [text](link)
Please give these links a text
You should also read more on this topic. You can refer to lots of codeforces blog.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Please use figure to support the explanation and be aware of the resolution. You should put more effort on explanation.
- You may refer to others PR or the article that has been merged into NTHU-CPP to know that what kind of article you have to write.
- https://nthu-cp.github.io/NTHU-CPP/graph/lca.html
- https://nthu-cp.github.io/NTHU-CPP/math/introduction_to_generating_function.html
- https://nthu-cp.github.io/NTHU-CPP/graph/introduction_to_AP_bridge.html
- https://nthu-cp.github.io/NTHU-CPP/graph/introduction_to_BCC.html
- https://nthu-cp.github.io/NTHU-CPP/greedy/basic.html
- https://nthu-cp.github.io/NTHU-CPP/sqrt/sqrt_decomposition.html
- Please rebase to the latest main branch and fix markdownlint and textlint.
- There should be two section
- Example problem: you should explain the problem in detail (including problem description, solution, code, time complexity/correctness analysis...). Also, please solve these problem with your own template code that mention above.
- Exercise problem: a problem list that reader may do if they want to practice treap, you don't have to explain these problem in detail, you may provide hint only.
- Please follow the format.
- You should read more resources and pick the best implementation (clean and fast)
friendly ping |
#35