mirror of
https://github.com/krahets/hello-algo.git
synced 2026-11-24 23:50:45 +08:00
Correct and unify doc snippets; fix errors in the demo sources (#2039)
Code snippets in the book are corrected and unified across languages and kept as literal blocks in the snippet files. The demo sources keep their #2033 form, with fixes only for real errors: wrong code, wrong printed labels, comments that contradict the code, and typos. en/ja/ko demos are rendered from the reviewed code dictionaries (krahets/hello-algo-workspace#78). Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
53611a0ae9
commit
4fd605c502
@@ -29,7 +29,7 @@ class ArrayQueue {
|
||||
return this.#queSize === 0;
|
||||
}
|
||||
|
||||
/* 큐에 삽입 */
|
||||
/* 원소 삽입 */
|
||||
push(num) {
|
||||
if (this.size === this.capacity) {
|
||||
console.log('큐가 가득 찼다');
|
||||
@@ -43,7 +43,7 @@ class ArrayQueue {
|
||||
this.#queSize++;
|
||||
}
|
||||
|
||||
/* 큐에서 꺼내기 */
|
||||
/* 원소 꺼내기 */
|
||||
pop() {
|
||||
const num = this.peek();
|
||||
// 맨 앞 포인터를 뒤로 한 칸 이동하고, 끝을 넘어가면 배열의 처음으로 돌아온다
|
||||
@@ -74,7 +74,7 @@ class ArrayQueue {
|
||||
const capacity = 10;
|
||||
const queue = new ArrayQueue(capacity);
|
||||
|
||||
/* 큐에 원소 삽입 */
|
||||
/* 원소 삽입 */
|
||||
queue.push(1);
|
||||
queue.push(3);
|
||||
queue.push(2);
|
||||
@@ -86,7 +86,7 @@ console.log('큐 queue =', queue.toArray());
|
||||
const peek = queue.peek();
|
||||
console.log('맨 앞 원소 peek = ' + peek);
|
||||
|
||||
/* 큐에서 원소 꺼내기 */
|
||||
/* 원소 꺼내기 */
|
||||
const pop = queue.pop();
|
||||
console.log('큐에서 꺼낸 원소 pop = ' + pop + ', 큐에서 꺼낸 후 queue =', queue.toArray());
|
||||
|
||||
@@ -102,5 +102,5 @@ console.log('큐가 비어 있는가 = ' + isEmpty);
|
||||
for (let i = 0; i < 10; i++) {
|
||||
queue.push(i);
|
||||
queue.pop();
|
||||
console.log('반복 ' + i + ' 회에서 삽입 + 꺼내기를 수행한 후 queue =', queue.toArray());
|
||||
console.log('반복 ' + i + ' 회차에서 삽입 + 꺼내기를 수행한 후 queue =', queue.toArray());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user