This commit is contained in:
krahets
2024-01-09 16:00:33 +08:00
parent 5b029ad632
commit 09d346e64d
90 changed files with 11430 additions and 648 deletions

View File

@@ -15,6 +15,8 @@
<link rel="canonical" href="https://www.hello-algo.com/en/chapter_stack_and_queue/summary/">
<link rel="prev" href="../deque/">
<link rel="icon" href="../../assets/images/favicon.png">
@@ -22,7 +24,7 @@
<title>Summary - Hello Algo</title>
<title>5.4 Summary - Hello Algo</title>
@@ -87,7 +89,7 @@
<div data-md-component="skip">
<a href="#summary" class="md-skip">
<a href="#54-summary" class="md-skip">
Skip to content
</a>
@@ -122,7 +124,7 @@
<div class="md-header__topic" data-md-component="header-topic">
<span class="md-ellipsis">
Summary
5.4 Summary
</span>
</div>
@@ -1083,6 +1085,220 @@
<li class="md-nav__item md-nav__item--active md-nav__item--nested">
<input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_6" checked>
<div class="md-nav__link md-nav__container">
<a href="../" class="md-nav__link ">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M17.36 20.2v-5.38h1.79V22H3v-7.18h1.8v5.38h12.56M6.77 14.32l.37-1.76 8.79 1.85-.37 1.76-8.79-1.85m1.16-4.21.76-1.61 8.14 3.78-.76 1.62-8.14-3.79m2.26-3.99 1.15-1.38 6.9 5.76-1.15 1.37-6.9-5.75m4.45-4.25L20 9.08l-1.44 1.07-5.36-7.21 1.44-1.07M6.59 18.41v-1.8h8.98v1.8H6.59Z"/></svg>
<span class="md-ellipsis">
Chapter 5. Stack and Queue
</span>
</a>
<label class="md-nav__link " for="__nav_6" id="__nav_6_label" tabindex="0">
<span class="md-nav__icon md-icon"></span>
</label>
</div>
<nav class="md-nav" data-md-level="1" aria-labelledby="__nav_6_label" aria-expanded="true">
<label class="md-nav__title" for="__nav_6">
<span class="md-nav__icon md-icon"></span>
Chapter 5. Stack and Queue
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../stack/" class="md-nav__link">
<span class="md-ellipsis">
5.1 Stack
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../queue/" class="md-nav__link">
<span class="md-ellipsis">
5.2 Queue
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../deque/" class="md-nav__link">
<span class="md-ellipsis">
5.3 Double-ended Queue
</span>
</a>
</li>
<li class="md-nav__item md-nav__item--active">
<input class="md-nav__toggle md-toggle" type="checkbox" id="__toc">
<label class="md-nav__link md-nav__link--active" for="__toc">
<span class="md-ellipsis">
5.4 Summary
</span>
<span class="md-nav__icon md-icon"></span>
</label>
<a href="./" class="md-nav__link md-nav__link--active">
<span class="md-ellipsis">
5.4 Summary
</span>
</a>
<nav class="md-nav md-nav--secondary" aria-label="Table of contents">
<label class="md-nav__title" for="__toc">
<span class="md-nav__icon md-icon"></span>
Table of contents
</label>
<ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>
<li class="md-nav__item">
<a href="#1-key-review" class="md-nav__link">
<span class="md-ellipsis">
1. &nbsp; Key Review
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#2-q-a" class="md-nav__link">
<span class="md-ellipsis">
2. &nbsp; Q &amp; A
</span>
</a>
</li>
</ul>
</nav>
</li>
</ul>
</nav>
</li>
</ul>
</nav>
</div>
@@ -1110,18 +1326,18 @@
<ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>
<li class="md-nav__item">
<a href="#key-review" class="md-nav__link">
<a href="#1-key-review" class="md-nav__link">
<span class="md-ellipsis">
Key Review
1. &nbsp; Key Review
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#q-a" class="md-nav__link">
<a href="#2-q-a" class="md-nav__link">
<span class="md-ellipsis">
Q &amp; A
2. &nbsp; Q &amp; A
</span>
</a>
@@ -1163,8 +1379,8 @@
<!-- Page content -->
<h1 id="summary">Summary<a class="headerlink" href="#summary" title="Permanent link">&para;</a></h1>
<h3 id="key-review">Key Review<a class="headerlink" href="#key-review" title="Permanent link">&para;</a></h3>
<h1 id="54-summary">5.4 &nbsp; Summary<a class="headerlink" href="#54-summary" title="Permanent link">&para;</a></h1>
<h3 id="1-key-review">1. &nbsp; Key Review<a class="headerlink" href="#1-key-review" title="Permanent link">&para;</a></h3>
<ul>
<li>A stack is a data structure that follows the Last-In-First-Out (LIFO) principle and can be implemented using either arrays or linked lists.</li>
<li>In terms of time efficiency, the array implementation of a stack has higher average efficiency, but during expansion, the time complexity for a single push operation can degrade to <span class="arithmatex">\(O(n)\)</span>. In contrast, the linked list implementation of a stack offers more stable efficiency.</li>
@@ -1172,7 +1388,7 @@
<li>A queue is a data structure that follows the First-In-First-Out (FIFO) principle, and it can also be implemented using either arrays or linked lists. The conclusions regarding time and space efficiency for queues are similar to those for stacks.</li>
<li>A double-ended queue is a more flexible type of queue that allows adding and removing elements from both ends.</li>
</ul>
<h3 id="q-a">Q &amp; A<a class="headerlink" href="#q-a" title="Permanent link">&para;</a></h3>
<h3 id="2-q-a">2. &nbsp; Q &amp; A<a class="headerlink" href="#2-q-a" title="Permanent link">&para;</a></h3>
<p><strong>Q</strong>: Is the browser's forward and backward functionality implemented with a doubly linked list?</p>
<p>The forward and backward functionality of a browser fundamentally represents the "stack" concept. When a user visits a new page, it is added to the top of the stack; when they click the back button, the page is popped from the top. A double-ended queue can conveniently implement some additional operations, as mentioned in the "Double-Ended Queue" section.</p>
<p><strong>Q</strong>: After popping from a stack, is it necessary to free the memory of the popped node?</p>
@@ -1204,6 +1420,27 @@ aria-label="Footer"
<!-- Link to previous page -->
<a
href="../deque/"
class="md-footer__link md-footer__link--prev"
aria-label="Previous: 5.3 Double-ended Queue"
rel="prev"
>
<div class="md-footer__button md-icon">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20 11v2H8l5.5 5.5-1.42 1.42L4.16 12l7.92-7.92L13.5 5.5 8 11h12Z"/></svg>
</div>
<div class="md-footer__title">
<span class="md-footer__direction">
Previous
</span>
<div class="md-ellipsis">
5.3 Double-ended Queue
</div>
</div>
</a>
<!-- Link to next page -->
@@ -1211,6 +1448,61 @@ aria-label="Footer"
<!-- Comment system -->
<h5 align="center" id="__comments">Feel free to drop your insights, questions or suggestions</h5>
<!-- Insert generated snippet here -->
<script
src="https://giscus.app/client.js"
data-repo="krahets/hello-algo"
data-repo-id="R_kgDOIXtSqw"
data-category="Announcements"
data-category-id="DIC_kwDOIXtSq84CSZk_"
data-mapping="pathname"
data-strict="1"
data-reactions-enabled="1"
data-emit-metadata="0"
data-input-position="top"
data-theme="preferred_color_scheme"
data-lang="en"
crossorigin="anonymous"
async
>
</script>
<!-- Synchronize Giscus theme with palette -->
<script>
var giscus = document.querySelector("script[src*=giscus]")
/* Set palette on initial load */
var palette = __md_get("__palette")
if (palette && typeof palette.color === "object") {
var theme = palette.color.scheme === "slate" ? "dark_dimmed" : "light"
giscus.setAttribute("data-theme", theme)
}
/* Register event handlers after documented loaded */
document.addEventListener("DOMContentLoaded", function() {
var ref = document.querySelector("[data-md-component=palette]")
ref.addEventListener("change", function() {
var palette = __md_get("__palette")
if (palette && typeof palette.color === "object") {
var theme = palette.color.scheme === "slate" ? "dark_dimmed" : "light"
/* Instruct Giscus to change theme */
var frame = document.querySelector(".giscus-frame")
frame.contentWindow.postMessage(
{ giscus: { setConfig: { theme } } },
"https://giscus.app"
)
}
})
})
</script>
</article>
</div>
@@ -1232,6 +1524,28 @@ aria-label="Footer"
<footer class="md-footer">
<nav class="md-footer__inner md-grid" aria-label="Footer" >
<a href="../deque/" class="md-footer__link md-footer__link--prev" aria-label="Previous: 5.3 Double-ended Queue">
<div class="md-footer__button md-icon">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20 11v2H8l5.5 5.5-1.42 1.42L4.16 12l7.92-7.92L13.5 5.5 8 11h12Z"/></svg>
</div>
<div class="md-footer__title">
<span class="md-footer__direction">
Previous
</span>
<div class="md-ellipsis">
5.3 Double-ended Queue
</div>
</div>
</a>
</nav>
<div class="md-footer-meta md-typeset">
<div class="md-footer-meta__inner md-grid">