倒排队列的渐近分析(Asymptotic Analysis of Reversing a Queue)
void reverseQueue(queue<int>& Queue) { stack<int> Stack; while (!Queue.empty()) { Stack.push(Queue.front()); Queue.pop(); } while (!Stack.empty()) { Queue.push(Stack.top()); Stack.pop(); } }
我想知道这个函数的Big-O或Big-Theta符号是什么,如果我们用n个元素的队列来调用它的话。 它会是沿着O(n ^ 2)行的东西,因为我们推动并弹出n个元素两次,以便将它从栈中移回到队列中,并且以相反的顺序排列? 感谢您的任何帮助。
void reverseQueue(queue<int>& Queue) { stack<int> Stack; while (!Queue.empty()) { Stack.push(Queue.front()); Queue.pop(); } while (!Stack.empty()) { Queue.push(Stack.top()); Stack.pop(); } }
I was wondering what the Big-O or Big-Theta notation of this function would be, if we called it with a Queue of n elements. Would it be something along the lines of O(n^2), since we're pushing and popping n elements twice in order to move it from the stack back to the queue in a reversed order? Thank you for any help.
原文:https://stackoverflow.com/questions/50283059
满意答案
所以我实际上最终解决了这个问题,方法是在Google地图上获取我所有标记的引用,然后将评级添加到与marker.getTitle()相关的字符串集中,并在getInfoWindow中对结果进行平均。
So I actually ended up fixing this problem by getting a reference to all of my markers on the Google map and then adding the ratings to a string set which correlated with the marker.getTitle(), and I average the results in the getInfoWindow.
相关问答
更多如何从膨胀的布局中获取数据(how to get data from inflated layout)
为什么setOnClickListener不适用于膨胀按钮?(why setOnClickListener not working for inflated button?)
ArrayAdapter无法从膨胀的布局访问Textviews(ArrayAdapter Unable to access Textviews from inflated Layout)
setRating不适用于膨胀的布局 - Android(setRating not working on an inflated layout-Android)
Android充气布局对齐(Android inflated layout alignment)
setText()不适用于虚拟布局(setText() not working on inflated layout)
更改ImageView可绘制的膨胀布局(Change ImageView drawable of an inflated layout)
为什么这种布局没有膨胀到全宽?(Why is this layout not inflated to full width?)
行布局在Android中没有膨胀(Row layout not inflated in Android)
Android - 从线性布局中删除膨胀的布局xml(Android - Removing inflated layout xml from a Linear Layout)
相关文章
更多Hadoop mapred-queue-acls 配置
zz Data Analysis Process
Solr参数(Analysis Collection Common CoreAdmin)
计算机病毒及其防治 Computer Virus Analysis and Antivirus
Solr官方文档系列——Text Analysis
企业级搜索引擎Solr 第二章 Schema和文本分析(Schema and Text Analysis)[2]
Becoming a data scientist
[译文] 恶意软件行为综述 - A View on Current Malware Behaviors
Spark - A Fault-Tolerant Abstraction for In-Memory Cluster Computing
Scaling Pinterest - From 0 To 10s Of Billions Of Page Views A Month In Two Years
最新问答
更多获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
如何通过引用返回对象?(How is returning an object by reference possible?)
矩阵如何存储在内存中?(How are matrices stored in memory?)
每个请求的Java新会话?(Java New Session For Each Request?)
css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
xcode语法颜色编码解释?(xcode syntax color coding explained?)
在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
Copyright ©2023 peixunduo.com All Rights Reserved.粤ICP备14003112号
本站部分内容来源于互联网,仅供学习和参考使用,请莫用于商业用途。如有侵犯你的版权,请联系我们(neng862121861#163.com),本站将尽快处理。谢谢合作!