星海's Blog

老头初学编程
算法导论 红黑树的实现代码(C++)
算法导论 动态顺序统计树练习题 14.1-3 14.1-4 14.1-5

算法导论思考题 13-4 Treap

星海 posted @ 2012年11月19日 02:17 in 数据结构与算法分析 , 2799 阅读
struct treap {
   type element;
   int priority ;

}

treap array[n]; //由用户构建一个带有元素与互异优先级的数组。

for (int i = 0; i < n; i++) {
   treePtr = treapTreeInsert(array[i].elemnt)  //执行普通的二叉树插入,保存插入后的节点
   while (treePtr != treepHeader && treePtr->priority < treePtr->parent->priority) {
     // treePtr不为树根,且优先级比其父节点小。
      if (treePtr = treePtr->parent->left)
        rightRorate(treePtr->parent);
      else
        leftRorate(treePtr->parent);


未经验证,有过有错,请指正评论或给我发EMAIL

Avatar_small
幽梦寻蝶 说:
2012年12月15日 11:07

henhao

Avatar_small
John 111 说:
2021年5月18日 23:15

This is my first time i visit here. I found so many interesting stuff in your blog especially its discussion. From the tons of comments on your articles, I guess I am not the only one having all the enjoyment here keep up the good work 안전놀이터

Avatar_small
John 111 说:
2021年6月17日 12:30

Please share more like that. earthhershop

Avatar_small
John 111 说:
2021年6月21日 14:02

I think this is an informative post and it is very useful and knowledgeable. therefore, I would like to thank you for the efforts you have made in writing this article. nextclippingpath

Avatar_small
John 111 说:
2021年6月25日 19:53

Took me time to read all the comments, but I really enjoyed the article. It proved to be Very helpful to me and I am sure to all the commenters here! It’s always nice when you can not only be informed, but also entertained! 먹튀검증

Avatar_small
Model Paper 2022 Pdf 说:
2021年11月02日 15:18

They begin their search for such preparation materials on the internet, hoping to find some good Question Papers pdf. So, in order to assist you, Question Paper 2022 Pdf we've compiled a list of the greatest Question Papers, which you can readily download from this page. Students who are studying often wonder which questions are most significant for the board test.

Avatar_small
sophia 说:
2024年2月08日 04:33

Cảm ơn bạn đã dành thời gian thảo luận về vấn đề này, tôi thực sự tin tưởng vào nó và muốn tìm hiểu thêm về chủ đề này. Nếu có thể, khi bạn có được kiến thức chuyên môn, bạn có phiền khi cập nhật blog của mình với thông tin bổ sung không? Nó là vô cùng hữu ích cho tôi. https://thabet.care /


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter