本系列博客習(xí)題來自《算法(第四版)》辞做,算是本人的讀書筆記,如果有人在讀這本書的闲礼,歡迎大家多多交流牍汹。為了方便討論,本人新建了一個微信群(算法交流)柬泽,想要加入的慎菲,請?zhí)砑游业奈⑿盘枺簔hujinhui207407 謝謝。另外锨并,本人的個人博客 http://www.kyson.cn 也在不停的更新中露该,歡迎一起討論
算法(第4版)
知識點
- 一個隊列實現(xiàn)的棧
題目
1.4.28 一個隊列實現(xiàn)的棧。使用一個隊列實現(xiàn)一個棧第煮,使得每個棧操作所需的隊列操作數(shù)量為線性級別解幼。
1.4.28 Stack with a queue. Implement a stack with a single queue so that each stack operations takes a linear number of queue operations. Hint : To delete an item, get all of the elements on the queue one at a time, and put them at the end, except for the last one which you should delete and return. (This solution is admittedly very inefficient.)