没有合适的资源?快使用搜索试试~ 我知道了~
算法与数据结构设计课件-Treaps.pdf
需积分: 5 0 下载量 64 浏览量
2023-06-12
14:37:17
上传
评论
收藏 446KB PDF 举报
温馨提示
试读
20页
Treaps binary search tree (BST) and heap
资源推荐
资源详情
资源评论
Hybrid of binary search tree (BST) and heap
every node has both a search key and a priority
(here: small value means high priority)
the inorder sequence of search keys is sorted
each node’s priority is smaller than the priorities of its children.
A treap is simultaneously a binary search tree for the search keys and a
(min-)heap for the priorities.
Will use letters for search keys and numbers for priorities
Design of Algorithms. . . Part 3 2021/22 3 / 20
Assume from now on that all the keys and priorities are distinct
Under this assumption, can prove by induction that the structure of a
treap is completely determined by the search keys and priorities of its
nodes.
Since it’s a heap, the node v with highest priority must be the root.
Since it’s also a binary search tree, any node u with key (u) < key(v )
must be in the left subtree, and any node w with key(w ) > key (v)
must be in the right subtree.
Finally, since the subtrees are treaps hemselves, by induction, their
structures are completely determined.
The base case is the trivial empty treap (or size 1 or 2 or 3. . . ).
Design of Algorithms. . . Part 3 2021/22 4 / 20
剩余19页未读,继续阅读
资源评论
m0_74043383
- 粉丝: 99
- 资源: 30
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功