数据结构三
左偏树可能各个方面都是最优的,可能他的最大缺点是插入操作O(n),但是综合并操作与代码难度考虑还是不错的选择
至于他的已知节点删除和变种没实现,待以后用的话再补上吧,觉得几乎没用处?(不敢说XD...
/**************************************** * LeftHeap.h * Describe: 可并优先队列——左偏树 * Created: 2010-5-27 * CopyRight 2010,Leek * ******************************************/ #include <iostream> #include <vector> #include <queue> using namespace std; typedef int Type; typedef struct LNode { Type key; int dis; LNode *left; LNode *right; LNode (Type key) { dis = 0; left = NULL; right = NULL; this->key = key; } }LNode; typedef LNode *PLNode; void Swap (int &a, int &b) { a ^= b, b ^= a, a ^= b; } void Swap (PLNode &a, PLNode &b) { PLNode tmp = a; a = b, b = tmp; } PLNode LHeap_Merge (PLNode a,PLNode b) { if (a == NULL) return b; if (b == NULL) return a; if (a->key > b->key) Swap (a->key,b->key); a->right = LHeap_Merge (a->right, b); if (a->left == NULL || a->right->dis > a->left->dis) Swap (a->right,a->left); if (a->right == NULL) a->dis = 0; else a->dis = a->right->dis + 1; return a; } PLNode LHeap_Build (queue<PLNode> &a) { PLNode tmp = a.front(); while (a.size() > 1) { a.pop(); tmp = LHeap_Merge (tmp,a.front()); a.push(tmp); a.pop(); tmp = a.front(); } return a.front(); } PLNode LHeap_Insert (Type key,PLNode root) { PLNode tmp = new LNode(key); return LHeap_Merge (tmp,root); } Type LHeap_Delete_Min (PLNode &root) { PLNode tmp = root; root = LHeap_Merge (root->left, root->right); Type top = tmp->key; delete tmp; return top; }
觉得建树和并操作值得思考多少有点启发性吧
顺便贴上败者树的模板 今天复习结束看漫画去
/**************************************** * Loser.h * Describe: 败者树 * Created: 2010-5-27 * CopyRight 2010,Leek * ******************************************/ #include <iostream> using namespace std; const int N = 1 << 16; //N大于n,并为2的次方 const int n = 234; typedef int Type; Type f[N * 2]; Type a[n]; void BuildTree (int n, int f[2 * N]) //建树a存在f N-N+n { memcpy (f + N,a,sizeof (a[0]) *n); for (int i = N,j = N + n - 1; i > 1;i >>= 1,j >>= 1) { for (int k = i; k < j;k += 2) f[k >> 1] = f[k] > f[k + 1] ? f[k] : f[k + 1]; //求得是最大值,可改为最小值 if (!(j&1)) f[j >> 1] = f[j]; } } int findmax (int s, int t) //查询s t中的最大 最小值 { int r = f[s] >= f[t]? s: t; for (int i = s,j = t; i < j; i >>= 1, j >>= 1) { if (!(i & 1) && i + 1 < j && f[i + 1] > f[r]) r = i + 1; if ((j & 1) && j - 1 > i && f[j - 1] > f[r]) r = j - 1; } return f[r]; //以下程序可求a【s t】最大最小值的下标 while (r < N) if (f[r] == f[r << 1]) r <<= 1; else if (f[r] == f[(r << 1) + 1]) r = (r << 1) + 1; }
2022年8月24日 21:07
The UP Board Class 11th Important Model Question Paper 2023 for the Intermediate 2023 Exams has been reduced by UPMSP. To learn about the units and topics along with the important model question paper 2023, students should refer to the most recent class 11th UP Board important model question paper. The topics mentioned in the UP Board's 11th Important Model Question Paper 2023 are the subjects of all the questions. Uttar Pradesh Intermediate Question Paper 2023, Students may view the English and Hindi-medium UP Board Question Bank for the 11th grade in this article. Important 2023 Model Exam Paper. These Important Model Question Paper 2023 are provided for students' planning purposes as a resource. The subjects for the 11th grade in Uttar Pradesh are listed below.
2023年11月01日 18:46
At times, we need to invest a ton energy to locate the working way. This is extraordinary stuff. I love the manner in which you utilized the syntax on this post. Cool much appreciated
2023年11月06日 22:40
The article you have shared is very interesting. I am really happy that I visit your webpage, and I am agree with what you said. Please keep sharing more
2023年11月06日 23:12
I got what you mean , thanks for posting .Woh I am happy to find this website through google.
2023年11月07日 16:16
I've perused yet. If it's not too much trouble keep this work going ahead in a similar quality.
2023年11月07日 21:21
Thank you so much for sharing this Informative article with us. I really love the way of your presentation. Please keep sharing more
2023年11月08日 19:14
I appreciated your work very thanks
2023年11月09日 14:34
really very helpful information..
2023年11月09日 14:47
Nice to be visiting your blog again, it has been months for me. Well this article that i've been waited for so long. I need this article to complete my assignment in the college, and it has same topic with your article. Thanks, great share
2023年11月09日 17:06
Great post i must say and thanks for the information. Education is definitely a sticky subject. However, is still among the leading topics of our time. I appreciate your post and look forward to more.
2023年11月09日 17:14
a awesome article
2023年11月09日 19:52
you continue to do your work like this in the future also
2023年11月09日 20:47
This is a wonderful article, Given so much info in it, These type of articles keeps the users interest in the website, and keep on sharing more ... good luck.
2023年11月09日 21:16
I would like to thank you for the efforts you have made in writing this article. I am hoping the same best work from you in the future as well. In fact your creative writing abilities has inspired me to start my own Blog Engine blog now. Really the blogging is spreading its wings rapidly. Your write up is a fine example of it
2023年11月12日 17:26
That is the excellent mindset, nonetheless is just not help to make every sence whatsoever preaching about that mather. Virtually any method many thanks in addition to i had endeavor to promote your own article in to delicius nevertheless it is apparently a dilemma using your information sites can you please recheck the idea. thanks once more
2023年11月13日 16:56
This is actually the kind of information I have been trying to find. Thank you for writing this information
2023年11月14日 16:37
최악의 부분은 소프트웨어가 간헐적으로 만 작동하고 데이터가 정확하지 않다는 것입니다. 정보가 올바르지 않으면 발견 한 내용에 대해 누구와도 대면 할 수 없습니다.
2023年11月14日 20:22
Great info! I recently came across your blog and have been reading along. I thought I would leave my first comment. I don’t know what to say except that I have
2023年11月15日 17:33
I want you to thank for your time of this wonderful read!!! I definately enjoy every little bit of it and I have you bookmarked to check out new stuff of your blog a must read blog!
2023年11月16日 23:02
I got what you mean , thanks for posting .Woh I am happy to find this website through google. <a href="https://www.bazanos.com/">메이저사이트</a>
2023年11月28日 13:24
Nice read, I just passed this onto a colleague who was doing some research on that. And he actually bought me lunch as I found it for him smile So let me rephrase that: Thank you for lunch!
2023年11月28日 14:17
This is a great inspiring article.I am pretty much pleased with your good work.You put really very helpful information. Keep it up. Keep blogging. Looking to reading your next pos
2023年11月28日 15:03
m excited to uncover this page. I need to to thank you for ones time for this particularly fantastic read!! I definitely really liked every part of it and i also have you saved to fav to look at new information in your site.
2023年11月28日 15:55
You bear through a awesome vacancy. I sanity definitely quarry it moreover personally suggest to my buddys. I am self-possessed they determination be benefited from this scene.
2023年11月28日 16:09
Oh my goodness! A wonderful located up dude. Thanks masses Even so We’re experiencing problem with ur rss . Don’t understand why Unable to sign up for it. Possibly there can be every body getting same rss predicament? Anybody who is aware about kindly respond. Thnkx
2023年11月28日 16:30
Wow, What an Outstanding post. I found this too much informatics. It is what I was seeking for. I would like to recommend you that please keep sharing such type of info.If possible, Thanks.
2023年11月28日 16:50
Hey, you used to write wonderful, but the last few posts have been kinda boring¡K I miss your great writings. Past few posts are just a bit out of track! come on!
2023年11月28日 17:00
https://scottchasserot.com/park/
2023年11月28日 17:06
This is a fantastic website, thanks for sharing. There’s no doubt i would fully rate it after i read what the idea about this article is. You did a nice
2023年11月28日 17:26
Hello! I realize this is kind of off-topic but I needed to ask. Does building a well-established website like yours take a massive amount work? I’m brand new to operating a blog however I do write in my journal daily. I’d like to start a blog so I can easily share my personal experience and thoughts online. Please let me know if you have any kind of ideas or tips for brand new aspiring bloggers. Appreciate it!
2023年11月28日 17:31
This is a great inspiring article.I am pretty much pleased with your good work.You put really very helpful information. Keep it up. Keep blogging. Looking to reading your next pos
2023年11月28日 18:21
Hello! I’ve been following your blog for a while now and finally got the courage to go ahead and give you a shout out from Kingwood Texas! Just wanted to mention keep up the good work!
2023年11月28日 18:22
Thank you for some other informative blog. Where else could I get that type of information written in such an ideal means? I have a mission that I’m just now working on, and I have been at the look out for such information.
2023年11月28日 18:58
This article gives the light in which we can observe the reality. This is very nice one and gives indepth information. Thanks for this nice article.
2023年11月28日 19:01
OtakuDesu is your top spot for all things anime and manga. With the latest episodes, reviews, and a thriving community, it's the perfect place for anime enthusiasts. Dive into the world of Otaku culture at OtakuDesu today.
2023年11月28日 19:23
This is a fantastic website, thanks for sharing. There’s no doubt i would fully rate it after i read what the idea about this article is. You did a nice
2023年11月28日 19:40
That is a thoroughly interesting blog post. I often visit your posts for help with my projects about Diwali Bumper Lottery and your super writing skills have truly amazed me.
2023年11月28日 19:48
Nice information, valuable and excellent design, as share good stuff with good ideas and concepts, lots of great information and inspiration, both of which I need, thanks to offer such a helpful information here.
2023年11月28日 20:07
I don’t apprehend whether or not or no longer it’s clearly me or if all of us else experiencing issues collectively collectively along with your blog. It seems like a number of the textual content interior your posts are walking off the display screen. Can somebody else please statement and allow me realise if this is taking vicinity to them too? This is probably a hassle with my net browser due to the fact I’ve had this take region in advance than. Appreciate it
2023年11月28日 20:11
Hello! I realize this is kind of off-topic but I needed to ask. Does building a well-established website like yours take a massive amount work? I’m brand new to operating a blog however I do write in my journal daily. I’d like to start a blog so I can easily share my personal experience and thoughts online. Please let me know if you have any kind of ideas or tips for brand new aspiring bloggers. Appreciate it!
2023年11月28日 20:25
Oh my goodness! A wonderful located up dude. Thanks masses Even so We’re experiencing problem with ur rss . Don’t understand why Unable to sign up for it. Possibly there can be every body getting same rss predicament? Anybody who is aware about kindly respond. Thnkx
2023年11月28日 20:31
Attractive, post. I just stumbled upon your weblog and wanted to say that I have liked browsing your blog posts. After all, I will surely subscribe to your feed, and I hope you will write again soon!
2023年11月28日 20:41
Greatly composed article, if just all bloggers offered a similar substance as you, the web would be a much better spot.
2023年11月28日 20:51
I want to start by saying thank you for the useful information you provided. I must admit that after reading the entire website, there is a ton of original, educational stuff. Kindly forward this kind of supplementary information to us.
2023年11月28日 21:12
m excited to uncover this page. I need to to thank you for ones time for this particularly fantastic read!! I definitely really liked every part of it and i also have you saved to fav to look at new information in your site.
2023年11月28日 21:27
Oh my goodness! A wonderful located up dude. Thanks masses Even so We’re experiencing problem with ur rss . Don’t understand why Unable to sign up for it. Possibly there can be every body getting same rss predicament? Anybody who is aware about kindly respond. Thnkx
2023年11月28日 21:39
Hello! I realize this is kind of off-topic but I needed to ask. Does building a well-established website like yours take a massive amount work? I’m brand new to operating a blog however I do write in my journal daily. I’d like to start a blog so I can easily share my personal experience and thoughts online. Please let me know if you have any kind of ideas or tips for brand new aspiring bloggers. Appreciate it!
2023年11月28日 21:48
My brother advocated I can also like this internet site. He become as quickly as virtually proper. This located up honestly made my day. You cannot take delivery of as true with surely how hundreds time I had spent for this information! Thanks!
2023年11月28日 22:11
I've been looking for well-written articles or blog entries about this topic for a long time. I finally came to this webpage after doing some research on Yahoo. After reading this, I'm glad to report that I firmly feel that I've found what I was looking for. This is definitely a webpage I'll remember and return to often.
2023年11月28日 22:25
Nice information, valuable and excellent design, as share good stuff with good ideas and concepts, lots of great information and inspiration, both of which I need, thanks to offer such a helpful information here.
2023年11月28日 22:40
OtakuDesu is your top spot for all things anime and manga. With the latest episodes, reviews, and a thriving community, it's the perfect place for anime enthusiasts. Dive into the world of Otaku culture at OtakuDesu today.
2023年11月28日 22:51
Hey, you used to write wonderful, but the last few posts have been kinda boring¡K I miss your great writings. Past few posts are just a bit out of track! come on!
2023年11月28日 23:01
You have done a great job. I will definitely dig it and personally recommend to my friends. I am confident they will be benefited from this site.
2023年11月28日 23:02
Hello! I’ve been following your blog for a while now and finally got the courage to go ahead and give you a shout out from Kingwood Texas! Just wanted to mention keep up the good work!
2023年11月28日 23:19
I don’t apprehend whether or not or no longer it’s clearly me or if all of us else experiencing issues collectively collectively along with your blog. It seems like a number of the textual content interior your posts are walking off the display screen. Can somebody else please statement and allow me realise if this is taking vicinity to them too? This is probably a hassle with my net browser due to the fact I’ve had this take region in advance than. Appreciate it
2023年12月07日 03:50
백링크 is your golden ticket to organic traffic. When other websites endorse your content, you not only gain valuable visitors but also signal to search engines that your content is authoritative.
2023年12月10日 18:35
Experience authentic conversations on 달리머넷. It's a valuable platform for sharing experiences and gaining insights.
2023年12月10日 19:07
I had a fantastic trip with 청주공항렌트카 Rental Mall 114.
2023年12月11日 21:08
오피가이드's expertise in OP is unmatched. I trust their recommendations for a memorable OP adventure.
2023年12月11日 22:26
티비몬's dedication to its viewers shines through its diverse content selection.
2023年12月12日 15:35
Heard 제주셔츠룸's decor is top-notch. Can't wait to witness the attention to detail firsthand.
2023年12月13日 18:49
Looking for a private escape? 오피's discreet services guarantee a memorable experience.
2023年12月13日 20:27
For thorough and reliable 설문조사 사이트 추천, choose Tipping.
2023年12月14日 18:51
모든 댓글을 읽는 데 시간이 걸렸지 만 기사를 정말 즐겼습니다. 그것은 나에게 매우 도움이되는 것으로 판명되었고 여기의 모든 댓글 작성자에게 확신합니다! 정보를받을 수있을뿐만 아니라 즐길 수있을 때 항상 좋습니다.
2023年12月16日 13:31
What your declaring is fully true. I know that everyone need to say the very same matter, but I just assume that you put it in a way that everybody can recognize. I also appreciate the images you place in the following. They match so properly with what youre making an attempt to say. Im positive youll get to so a lot of people today with what youve received to say. 스포츠중계
2023年12月17日 23:09
강남휴게텔 is my haven for rejuvenation. The aroma massage is a sensory delight, and the personalized service ensures a memorable experience every time.
2023年12月20日 17:35
The content diversity on 누누티비 ensures I never run out of things to watch.
2023年12月23日 21:43
무료실시간TV중계 brings the stadium experience to your screen with its high-definition streaming. It's a sports lover's dream come true.
2023年12月24日 15:20
티비위키 brings people together over shared entertainment interests.
2023年12月28日 20:41
I can’t imagine focusing long enough to research; much less write this kind of article. You’ve outdone yourself with this material. This is great content.
2023年12月31日 13:47
Hey man, .This was an excellent page for such a hard subject to talk about. I look forward to reading many more great posts like these. Thanks 카지노사이트
2024年1月04日 21:33
We read the content space to cover the idea move from the power zone. I allow you to response the content with the help of new added portions. I love to follow it
2024年1月07日 16:24
"나는 그러한 주제에 관심이 있으므로 멋진 설명 페이지를 언급하겠습니다.
2024年1月11日 15:07
확실히 그것의 모든 조금을 즐기십시오. 그리고 나는 당신의 블로그의 새로운 내용을 확인하기 위해 당신이 즐겨 찾기에 추가했습니다. 반드시 읽어야 할 블로그입니다!
2024年1月15日 16:23
I think this internet site contains very fantastic written subject matter blog posts. เว็บบอลคืนยอดเสีย
2024年1月15日 16:52
I found your documents very interesting. You have a amazing skills of writing a brief content. Thanks for talking about this, it is really a useful for me. I am going to preserve this.
2024年1月15日 21:51
Wonderful article. Thanks too much for the breakdown you have presented here. I am still sort-of an illiterate on this topic. So this post was really helpful to me personally. My husband just launched his own ebook on this issue and I think some things learned from your post would enable me personally to give him the necessary support. Thanks!
2024年1月15日 22:21
A superbly written article, if only all bloggers offered the same content as you, the internet would be a far better place
2024年1月15日 22:39
Hey there! I simply wish to give you a huge thumbs up for the great information you’ve got right here on this post. I am coming back to your website for more soon.
2024年1月16日 14:32
You have a real ability for writing unique content. I like how you think and the way you represent your views in this article. I agree with your way of thinking. Thank you for sharing
2024年1月16日 14:59
The article you have shared is very interesting. I am really happy that I visit your webpage, and I am agree with what you said. Please keep sharing more
2024年1月16日 15:14
Its a great pleasure reading your post.Its full of information I am looking for and I love to post a comment that "The content of your post is awesome" Great work
2024年1月16日 15:31
Hi, great service, I really saw the traffic on my website, not conversions yet, I am sure this was quality traffic, anyway, I will come back again.
2024年1月16日 15:49
Its a great pleasure reading your post.Its full of information I am looking for and I love to post a comment that "The content of your post is awesome" Great work
2024年1月16日 16:08
You there, this is really good post here. Thanks for taking the time to post such valuable information. Quality content is what always gets the visitors coming
2024年1月16日 16:25
Very interesting, good job and thanks for sharing such a good blog. your article is so convincing that I never stop myself to say something about it. You’re doing a great job. Keep it up
2024年1月16日 16:50
This is a smart blog. I mean it. You have so much knowledge about this issue, and so much passion. You also know how to make people rally behind it, obviously from the responses.
2024年1月16日 17:56
I have read your article, it is very informative and helpful for me. I admire the valuable information you offer in your articles. Thanks for posting it
2024年1月16日 22:05
I feel very grateful that I read this. It is very helpful and very informative and I really learned a lot from it.
2024年1月18日 14:24
Happy with the website and the team.
2024年1月22日 16:34
온라인 카지노 커뮤니티 온카허브 입니다. 온카허브는 카지노 먹튀 사이트들과 안전한 카지노 사이트 정보를 공유하고 있습니다. 카지노 먹튀검증 전문팀을 자체적으로 운영함으로써 철저한 검증을 진행하고 있습니다.
2024年1月22日 16:42
온라인 카지노 커뮤니티 온카허브 입니다. 온카허브는 카지노 먹튀 사이트들과 안전한 카지노 사이트 정보를 공유하고 있습니다. 카지노 먹튀검증 전문팀을 자체적으로 운영함으로써 철저한 검증을 진행하고 있습니다.
https://oncahub24.com/
2024年1月24日 11:37
바카라 바카라사이트 우리카지노 카지노는 바카라, 블랙잭, 룰렛 및 슬롯 등 다양한 게임을 즐기실 수 있는 공간입니다. 게임에서 승리하면 큰 환호와 함께 많은 당첨금을 받을 수 있고, 패배하면 아쉬움과 실망을 느끼게 됩니다.
2024年1月24日 12:17
하노이 꼭 가봐야 할 베스트 업소 추천 안내 및 예약, 하노이 밤문화 에 대해서 정리해 드립니다. 하노이 가라오케, 하노이 마사지, 하노이 풍선바, 하노이 밤문화를 제대로 즐기시기 바랍니다. 하노이 밤문화 베스트 업소 요약 베스트 업소 추천 및 정리.
2024年1月25日 15:00
No.1 먹튀검증 사이트, 먹튀사이트, 검증사이트, 토토사이트, 안전사이트, 메이저사이트, 안전놀이터 정보를 제공하고 있습니다. 먹튀해방으로 여러분들의 자산을 지켜 드리겠습니다. 먹튀검증 전문 커뮤니티 먹튀클린만 믿으세요!!
2024年1月25日 16:23
베트남 남성전용 커뮤니티❣️ 베트남 하이에나 에서 베트남 밤문화를 추천하여 드립니다. 베트남 가라오케, 베트남 VIP마사지, 베트남 이발관, 베트남 황제투어 남자라면 꼭 한번은 경험 해 봐야할 화끈한 밤문화로 모시겠습니다.
2024年4月23日 18:16
블록체인개발 코인지갑개발 IT컨설팅 메스브레인팀이 항상 당신을 도울 준비가 되어 있습니다. 우리는 마음으로 가치를 창조한다는 철학을 바탕으로 일하며, 들인 노력과 시간에 부흥하는 가치만을 받습니다. 고객이 만족하지 않으면 기꺼이 환불해 드립니다.
https://xn--539awa204jj6kpxc0yl.kr/
2024年6月03日 12:20
The tech-original mission is to help you better understand technology, and make better decisions in the fields of IT, Tech, and Crypto.
https://www.tech-original.com/
2024年6月07日 18:03
The tech-original mission is to help you better understand technology, and make better decisions in the fields of IT, Tech, and Crypto.
https://www.tech-original.com/