首页 > 解决方案 > 摊销时间复杂度双端队列

问题描述

我需要使用 3 个堆栈分析一个简单双端队列的摊销时间复杂度,我需要使用潜在方法,但我无法找到潜在函数。使用非常简单(可能效率不高,但无论如何):

PushTop : enters stack1
PushBottn: enters stack3
popTop: the queue is not empty
if isEmpty s1
   if is Empty s2
     move from s3 to s1
    move from s2 to s2 
popS1

poshBottom: the queue is not empty
if isEmpty s3
   if is Empty s2
      move from s1 to s3
   pops2
pops3 


标签: stackqueuetime-complexitydequeamortized-analysis

解决方案


推荐阅读